Skip to content

Commit 9bd77a9

Browse files
ZhaoQiang-b45475broonie
authored andcommitted
spi: fsl-dspi: fix wrong pointer in suspend/resume
Since commit 530b5af ("spi: fsl-dspi: fix use-after-free in remove path"), this driver causes a "NULL pointer dereference" in dspi_suspend/resume. This is because since this commit, the drivers private data point to "dspi" instead of "ctlr", the codes in suspend and resume func were not modified correspondly. Fixes: 530b5af ("spi: fsl-dspi: fix use-after-free in remove path") Signed-off-by: Zhao Qiang <qiang.zhao@nxp.com> Reviewed-by: Vladimir Oltean <olteanv@gmail.com> Link: https://lore.kernel.org/r/20201103020546.1822-1-qiang.zhao@nxp.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 5e31ba0 commit 9bd77a9

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

drivers/spi/spi-fsl-dspi.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,12 +1080,11 @@ MODULE_DEVICE_TABLE(of, fsl_dspi_dt_ids);
10801080
#ifdef CONFIG_PM_SLEEP
10811081
static int dspi_suspend(struct device *dev)
10821082
{
1083-
struct spi_controller *ctlr = dev_get_drvdata(dev);
1084-
struct fsl_dspi *dspi = spi_controller_get_devdata(ctlr);
1083+
struct fsl_dspi *dspi = dev_get_drvdata(dev);
10851084

10861085
if (dspi->irq)
10871086
disable_irq(dspi->irq);
1088-
spi_controller_suspend(ctlr);
1087+
spi_controller_suspend(dspi->ctlr);
10891088
clk_disable_unprepare(dspi->clk);
10901089

10911090
pinctrl_pm_select_sleep_state(dev);
@@ -1095,16 +1094,15 @@ static int dspi_suspend(struct device *dev)
10951094

10961095
static int dspi_resume(struct device *dev)
10971096
{
1098-
struct spi_controller *ctlr = dev_get_drvdata(dev);
1099-
struct fsl_dspi *dspi = spi_controller_get_devdata(ctlr);
1097+
struct fsl_dspi *dspi = dev_get_drvdata(dev);
11001098
int ret;
11011099

11021100
pinctrl_pm_select_default_state(dev);
11031101

11041102
ret = clk_prepare_enable(dspi->clk);
11051103
if (ret)
11061104
return ret;
1107-
spi_controller_resume(ctlr);
1105+
spi_controller_resume(dspi->ctlr);
11081106
if (dspi->irq)
11091107
enable_irq(dspi->irq);
11101108

0 commit comments

Comments
 (0)