[PATCH 5.16 009/203] mmc: sh_mmcif: Check for null res pointer
From: Greg Kroah-Hartman
Date: Mon Feb 14 2022 - 05:22:46 EST
From: Jiasheng Jiang <jiasheng@xxxxxxxxxxx>
commit 4d315357b3d6c315a7260420c6c6fc076e58d14b upstream.
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@xxxxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx # v5.16+
Link: https://lore.kernel.org/r/20220119120006.1426964-1-jiasheng@xxxxxxxxxxx
Signed-off-by: Ulf Hansson <ulf.hansson@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
drivers/mmc/host/sh_mmcif.c | 3 +++
1 file changed, 3 insertions(+)
--- 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(str
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) {