Message ID | 20200922093228.24917-5-s.hauer@pengutronix.de |
---|---|
State | New |
Headers | show |
Series | [1/6] spi: fsl-dspi: Use devm_spi_register_controller() | expand |
diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c index 323c66c5db50..caeece6681b3 100644 --- a/drivers/spi/spi-dw-core.c +++ b/drivers/spi/spi-dw-core.c @@ -485,7 +485,7 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws) } } - ret = spi_register_controller(master); + ret = devm_spi_register_controller(dev, master); if (ret) { dev_err(&master->dev, "problem registering spi master\n"); goto err_dma_exit; @@ -509,8 +509,6 @@ void dw_spi_remove_host(struct dw_spi *dws) { dw_spi_debugfs_remove(dws); - spi_unregister_controller(dws->master); - if (dws->dma_ops && dws->dma_ops->dma_exit) dws->dma_ops->dma_exit(dws);
Calling spi_unregister_controller() during driver remove results in freeing the SPI controller and the associated driver data. Using it later in dw_spi_remove_host() 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/spi-dw-core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)