mmc: dw_mmc: Fix potential null pointer risk
authorWen Zhiwei <wenzhiwei@kylinos.cn>
Wed, 29 Dec 2021 02:38:14 +0000 (10:38 +0800)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 28 Feb 2022 12:06:20 +0000 (13:06 +0100)
we previously assumed 'host->slot' could be null,
null pointer judgment should be added

Signed-off-by: Wen Zhiwei <wenzhiwei@kylinos.cn>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
Link: https://lore.kernel.org/r/20211229023814.53372-1-wenzhiwei@kylinos.cn
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/dw_mmc.c

index 42bf8a2287ba7a0deabc71c0969435fd4239f61f..99b201921954b1f9ac6c5d7f2694e06777343ec0 100644 (file)
@@ -3568,7 +3568,7 @@ int dw_mci_runtime_resume(struct device *dev)
        mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE);
 
 
-       if (host->slot->mmc->pm_flags & MMC_PM_KEEP_POWER)
+       if (host->slot && host->slot->mmc->pm_flags & MMC_PM_KEEP_POWER)
                dw_mci_set_ios(host->slot->mmc, &host->slot->mmc->ios);
 
        /* Force setup bus to guarantee available clock output */