* [PATCH v2 1/5] spi: imx: fix use-after-free on unbind
[not found] <20260324082326.901043-1-johan@kernel.org>
@ 2026-03-24 8:23 ` Johan Hovold
2026-03-24 8:23 ` [PATCH v2 2/5] spi: rockchip: fix controller deregistration Johan Hovold
1 sibling, 0 replies; 2+ messages in thread
From: Johan Hovold @ 2026-03-24 8:23 UTC (permalink / raw)
To: Mark Brown
Cc: Frank Li, Sascha Hauer, Heiko Stuebner, Laxman Dewangan,
Marc Kleine-Budde, linux-spi, linux-kernel, Johan Hovold, stable
The SPI subsystem frees the controller and any subsystem allocated
driver data as part of deregistration (unless the allocation is device
managed).
Take another reference before deregistering the controller so that the
driver data is not freed until the driver is done with it.
Fixes: 307c897db762 ("spi: spi-imx: replace struct spi_imx_data::bitbang by pointer to struct spi_controller")
Cc: stable@vger.kernel.org # 5.19
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/spi/spi-imx.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index 64c6c09e1e7b..a8d90c86a8a1 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -2401,6 +2401,8 @@ static void spi_imx_remove(struct platform_device *pdev)
struct spi_imx_data *spi_imx = spi_controller_get_devdata(controller);
int ret;
+ spi_controller_get(controller);
+
spi_unregister_controller(controller);
ret = pm_runtime_get_sync(spi_imx->dev);
@@ -2414,6 +2416,8 @@ static void spi_imx_remove(struct platform_device *pdev)
pm_runtime_disable(spi_imx->dev);
spi_imx_sdma_exit(spi_imx);
+
+ spi_controller_put(controller);
}
static int spi_imx_runtime_resume(struct device *dev)
--
2.52.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* [PATCH v2 2/5] spi: rockchip: fix controller deregistration
[not found] <20260324082326.901043-1-johan@kernel.org>
2026-03-24 8:23 ` [PATCH v2 1/5] spi: imx: fix use-after-free on unbind Johan Hovold
@ 2026-03-24 8:23 ` Johan Hovold
1 sibling, 0 replies; 2+ messages in thread
From: Johan Hovold @ 2026-03-24 8:23 UTC (permalink / raw)
To: Mark Brown
Cc: Frank Li, Sascha Hauer, Heiko Stuebner, Laxman Dewangan,
Marc Kleine-Budde, linux-spi, linux-kernel, Johan Hovold, stable,
addy ke
Make sure to deregister the controller before freeing underlying
resources like DMA channels during driver unbind.
Fixes: 64e36824b32b ("spi/rockchip: add driver for Rockchip RK3xxx SoCs integrated SPI")
Cc: stable@vger.kernel.org # 3.17
Cc: addy ke <addy.ke@rock-chips.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/spi/spi-rockchip.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
index fd2ebef4903f..eb1992b4178e 100644
--- a/drivers/spi/spi-rockchip.c
+++ b/drivers/spi/spi-rockchip.c
@@ -908,7 +908,7 @@ static int rockchip_spi_probe(struct platform_device *pdev)
break;
}
- ret = devm_spi_register_controller(&pdev->dev, ctlr);
+ ret = spi_register_controller(ctlr);
if (ret < 0) {
dev_err(&pdev->dev, "Failed to register controller\n");
goto err_free_dma_rx;
@@ -936,6 +936,8 @@ static void rockchip_spi_remove(struct platform_device *pdev)
pm_runtime_get_sync(&pdev->dev);
+ spi_unregister_controller(ctlr);
+
pm_runtime_put_noidle(&pdev->dev);
pm_runtime_disable(&pdev->dev);
pm_runtime_set_suspended(&pdev->dev);
--
2.52.0
^ permalink raw reply related [flat|nested] 2+ messages in thread