Skip to content

Commit 2c914aa

Browse files
tlebgregkh
authored andcommitted
spi: cadence-qspi: fix pointer reference in runtime PM hooks
commit 32ce3bb57b6b402de2aec1012511e7ac4e7449dc upstream. 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: 2087e85bb66e ("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]> Signed-off-by: Zhaoyang Li <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 55bf541 commit 2c914aa

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
@@ -1775,10 +1775,9 @@ static int cqspi_remove(struct platform_device *pdev)
17751775
static int cqspi_suspend(struct device *dev)
17761776
{
17771777
struct cqspi_st *cqspi = dev_get_drvdata(dev);
1778-
struct spi_master *master = dev_get_drvdata(dev);
17791778
int ret;
17801779

1781-
ret = spi_master_suspend(master);
1780+
ret = spi_master_suspend(cqspi->master);
17821781
cqspi_controller_enable(cqspi, 0);
17831782

17841783
clk_disable_unprepare(cqspi->clk);
@@ -1789,7 +1788,6 @@ static int cqspi_suspend(struct device *dev)
17891788
static int cqspi_resume(struct device *dev)
17901789
{
17911790
struct cqspi_st *cqspi = dev_get_drvdata(dev);
1792-
struct spi_master *master = dev_get_drvdata(dev);
17931791

17941792
clk_prepare_enable(cqspi->clk);
17951793
cqspi_wait_idle(cqspi);
@@ -1798,7 +1796,7 @@ static int cqspi_resume(struct device *dev)
17981796
cqspi->current_cs = -1;
17991797
cqspi->sclk = 0;
18001798

1801-
return spi_master_resume(master);
1799+
return spi_master_resume(cqspi->master);
18021800
}
18031801

18041802
static DEFINE_SIMPLE_DEV_PM_OPS(cqspi_dev_pm_ops, cqspi_suspend, cqspi_resume);

0 commit comments

Comments
 (0)