From: Sascha Hauer <s.hauer@pengutronix.de>
To: linux-spi@vger.kernel.org
Cc: Mark Brown <broonie@kernel.org>,
Nicolas Ferre <nicolas.ferre@microchip.com>,
Nicolas Saenz Julienne <nsaenzjulienne@suse.de>,
Vladimir Oltean <olteanv@gmail.com>,
Daniel Mack <daniel@zonque.org>,
kernel@pengutronix.de, Sascha Hauer <s.hauer@pengutronix.de>
Subject: [PATCH 2/6] spi: atmel-quadspi: Use devm_spi_register_controller()
Date: Tue, 22 Sep 2020 11:32:24 +0200 [thread overview]
Message-ID: <20200922093228.24917-3-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20200922093228.24917-1-s.hauer@pengutronix.de>
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@pengutronix.de>
---
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
next prev parent reply other threads:[~2020-09-22 9:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-22 9:32 [PATCH 0/6] Fix use-after-free in SPI drivers Sascha Hauer
2020-09-22 9:32 ` [PATCH 1/6] spi: fsl-dspi: Use devm_spi_register_controller() Sascha Hauer
2020-09-22 9:44 ` Mark Brown
2020-09-22 11:06 ` Sascha Hauer
2020-09-22 11:25 ` Mark Brown
2020-09-22 9:32 ` Sascha Hauer [this message]
2020-09-22 9:32 ` [PATCH 3/6] spi: bcm2835: " Sascha Hauer
2020-09-22 9:39 ` Nicolas Saenz Julienne
2020-09-22 9:32 ` [PATCH 4/6] spi: dw: " Sascha Hauer
2020-09-22 9:32 ` [PATCH 5/6] spi: pxa2xx: " Sascha Hauer
2020-09-22 9:32 ` [PATCH 6/6] spi: rpc-if: " Sascha Hauer
2020-10-15 5:44 ` [PATCH 0/6] Fix use-after-free in SPI drivers Lukas Wunner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200922093228.24917-3-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=broonie@kernel.org \
--cc=daniel@zonque.org \
--cc=kernel@pengutronix.de \
--cc=linux-spi@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=nsaenzjulienne@suse.de \
--cc=olteanv@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).