summaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorJiasheng Jiang <jiasheng@iscas.ac.cn>2022-01-19 13:00:06 +0100
committerUlf Hansson <ulf.hansson@linaro.org>2022-01-24 15:37:13 +0100
commit4d315357b3d6c315a7260420c6c6fc076e58d14b (patch)
treedadb05ce322add2639743003eababc517314dc6c /drivers/mmc
parentmmc: sdhci-of-esdhc: Check for error num after setting mask (diff)
downloadlinux-4d315357b3d6c315a7260420c6c6fc076e58d14b.tar.xz
linux-4d315357b3d6c315a7260420c6c6fc076e58d14b.zip
mmc: sh_mmcif: Check for null res pointer
If there is no suitable resource, platform_get_resource() will return NULL. Therefore in order to avoid the dereference of the NULL pointer, it should be better to check the 'res'. Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn> Cc: stable@vger.kernel.org # v5.16+ Link: https://lore.kernel.org/r/20220119120006.1426964-1-jiasheng@iscas.ac.cn Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/host/sh_mmcif.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
index bcc595c70a9f..104dcd702870 100644
--- a/drivers/mmc/host/sh_mmcif.c
+++ b/drivers/mmc/host/sh_mmcif.c
@@ -405,6 +405,9 @@ static int sh_mmcif_dma_slave_config(struct sh_mmcif_host *host,
struct dma_slave_config cfg = { 0, };
res = platform_get_resource(host->pd, IORESOURCE_MEM, 0);
+ if (!res)
+ return -EINVAL;
+
cfg.direction = direction;
if (direction == DMA_DEV_TO_MEM) {