[PATCH 2/6] spi: atmel-quadspi: Use devm_spi_register_controller()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Calling spi_unregister_controller() during driver remove results in
freeing the SPI controller and the associated driver data. Using it
later in atmel_qspi_remove() is a use-after-free bug. Register the
controller with devm_spi_register_controller() instead which makes
calling spi_unregister_controller() unnecessary.

Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 drivers/spi/atmel-quadspi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/spi/atmel-quadspi.c b/drivers/spi/atmel-quadspi.c
index 8c009c175f2c..3a5e0703bad9 100644
--- a/drivers/spi/atmel-quadspi.c
+++ b/drivers/spi/atmel-quadspi.c
@@ -628,7 +628,7 @@ static int atmel_qspi_probe(struct platform_device *pdev)
 
 	atmel_qspi_init(aq);
 
-	err = spi_register_controller(ctrl);
+	err = devm_spi_register_controller(&pdev->dev, ctrl);
 	if (err)
 		goto disable_qspick;
 
@@ -649,7 +649,6 @@ static int atmel_qspi_remove(struct platform_device *pdev)
 	struct spi_controller *ctrl = platform_get_drvdata(pdev);
 	struct atmel_qspi *aq = spi_controller_get_devdata(ctrl);
 
-	spi_unregister_controller(ctrl);
 	atmel_qspi_write(QSPI_CR_QSPIDIS, aq, QSPI_CR);
 	clk_disable_unprepare(aq->qspick);
 	clk_disable_unprepare(aq->pclk);
-- 
2.28.0




[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux