Skip to content

Commit f99165e

Browse files
jhovoldgregkh
authored andcommitted
spi: imx: fix use-after-free on unbind
commit 1c78c20 upstream. 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: 307c897 ("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> Link: https://patch.msgid.link/20260324082326.901043-2-johan@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8c43ed0 commit f99165e

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

drivers/spi/spi-imx.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,6 +1898,8 @@ static void spi_imx_remove(struct platform_device *pdev)
18981898
struct spi_imx_data *spi_imx = spi_controller_get_devdata(controller);
18991899
int ret;
19001900

1901+
spi_controller_get(controller);
1902+
19011903
spi_unregister_controller(controller);
19021904

19031905
ret = pm_runtime_get_sync(spi_imx->dev);
@@ -1911,6 +1913,8 @@ static void spi_imx_remove(struct platform_device *pdev)
19111913
pm_runtime_disable(spi_imx->dev);
19121914

19131915
spi_imx_sdma_exit(spi_imx);
1916+
1917+
spi_controller_put(controller);
19141918
}
19151919

19161920
static int __maybe_unused spi_imx_runtime_resume(struct device *dev)

0 commit comments

Comments
 (0)