Skip to content

Commit 32ce3bb

Browse files
tlebbroonie
authored andcommitted
spi: cadence-qspi: fix pointer reference in runtime PM hooks
dev_get_drvdata() gets used to acquire the pointer to cqspi and the SPI controller. Neither embed the other; this lead to memory corruption. On a given platform (Mobileye EyeQ5) the memory corruption is hidden inside cqspi->f_pdata. Also, this uninitialised memory is used as a mutex (ctlr->bus_lock_mutex) by spi_controller_suspend(). Fixes: 2087e85 ("spi: cadence-quadspi: fix suspend-resume implementations") Reviewed-by: Dhruva Gole <[email protected]> Signed-off-by: Théo Lebrun <[email protected]> Link: https://msgid.link/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 269e31a commit 32ce3bb

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

drivers/spi/spi-cadence-quadspi.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,10 +1930,9 @@ static void cqspi_remove(struct platform_device *pdev)
19301930
static int cqspi_suspend(struct device *dev)
19311931
{
19321932
struct cqspi_st *cqspi = dev_get_drvdata(dev);
1933-
struct spi_controller *host = dev_get_drvdata(dev);
19341933
int ret;
19351934

1936-
ret = spi_controller_suspend(host);
1935+
ret = spi_controller_suspend(cqspi->host);
19371936
cqspi_controller_enable(cqspi, 0);
19381937

19391938
clk_disable_unprepare(cqspi->clk);
@@ -1944,7 +1943,6 @@ static int cqspi_suspend(struct device *dev)
19441943
static int cqspi_resume(struct device *dev)
19451944
{
19461945
struct cqspi_st *cqspi = dev_get_drvdata(dev);
1947-
struct spi_controller *host = dev_get_drvdata(dev);
19481946

19491947
clk_prepare_enable(cqspi->clk);
19501948
cqspi_wait_idle(cqspi);
@@ -1953,7 +1951,7 @@ static int cqspi_resume(struct device *dev)
19531951
cqspi->current_cs = -1;
19541952
cqspi->sclk = 0;
19551953

1956-
return spi_controller_resume(host);
1954+
return spi_controller_resume(cqspi->host);
19571955
}
19581956

19591957
static DEFINE_RUNTIME_DEV_PM_OPS(cqspi_dev_pm_ops, cqspi_suspend,

0 commit comments

Comments
 (0)