diff mbox series

[-next,1/2] spi: microchip-core: fix UAF in mchp_corespi_remove()

Message ID 20220712135357.918997-1-yangyingliang@huawei.com (mailing list archive)
State New, archived
Headers show
Series [-next,1/2] spi: microchip-core: fix UAF in mchp_corespi_remove() | expand

Commit Message

Yang Yingliang July 12, 2022, 1:53 p.m. UTC
When using devm_spi_register_master(), the unregister function will
be called in devres_release_all() which is called after ->remove(),
so remove spi_unregister_master() andspi_master_put().

Fixes: 9ac8d17694b6 ("spi: add support for microchip fpga spi controllers")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/spi/spi-microchip-core.c | 2 --
 1 file changed, 2 deletions(-)

Comments

Conor Dooley July 12, 2022, 8:52 p.m. UTC | #1
On 12/07/2022 14:53, Yang Yingliang wrote:
> When using devm_spi_register_master(), the unregister function will
> be called in devres_release_all() which is called after ->remove(),
> so remove spi_unregister_master() andspi_master_put().
> 
> Fixes: 9ac8d17694b6 ("spi: add support for microchip fpga spi controllers")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>

With 59ebbe40fb51 ("spi: simplify devm_spi register_controller") reverted,
this looks good to me.

Reviewed-by: Conor Dooley <conor.dooley@microchip.com>

Thanks!

> ---
>  drivers/spi/spi-microchip-core.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/spi/spi-microchip-core.c b/drivers/spi/spi-microchip-core.c
> index b3083075cd36..c26767343176 100644
> --- a/drivers/spi/spi-microchip-core.c
> +++ b/drivers/spi/spi-microchip-core.c
> @@ -595,8 +595,6 @@ static int mchp_corespi_remove(struct platform_device *pdev)
>  	struct mchp_corespi *spi = spi_master_get_devdata(master);
>  
>  	mchp_corespi_disable_ints(spi);
> -	spi_unregister_master(master);
> -	spi_master_put(master);
>  	clk_disable_unprepare(spi->clk);
>  	mchp_corespi_disable(spi);
>
diff mbox series

Patch

diff --git a/drivers/spi/spi-microchip-core.c b/drivers/spi/spi-microchip-core.c
index b3083075cd36..c26767343176 100644
--- a/drivers/spi/spi-microchip-core.c
+++ b/drivers/spi/spi-microchip-core.c
@@ -595,8 +595,6 @@  static int mchp_corespi_remove(struct platform_device *pdev)
 	struct mchp_corespi *spi = spi_master_get_devdata(master);
 
 	mchp_corespi_disable_ints(spi);
-	spi_unregister_master(master);
-	spi_master_put(master);
 	clk_disable_unprepare(spi->clk);
 	mchp_corespi_disable(spi);