From: Zhang Changzhong Date: Fri, 4 Dec 2020 08:31:57 +0000 (+0800) Subject: memory: jz4780_nemc: Fix potential NULL dereference in jz4780_nemc_probe() X-Git-Tag: v5.10.7~630 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d7af811f2e745ecd3495b21f80e3cb007ef54af4;p=platform%2Fkernel%2Flinux-rpi.git memory: jz4780_nemc: Fix potential NULL dereference in jz4780_nemc_probe() [ Upstream commit 4bfa07300b9334b487ed4f3d4901c35ebb31b7ca ] platform_get_resource() may fail and return NULL, so we should better check it's return value to avoid a NULL pointer dereference a bit later in the code. This is detected by Coccinelle semantic patch. Fixes: 911a88829725 ("memory: jz4780-nemc: driver for the NEMC on JZ4780 SoCs") Signed-off-by: Zhang Changzhong Acked-by: Paul Cercueil Link: https://lore.kernel.org/r/1607070717-32880-1-git-send-email-zhangchangzhong@huawei.com Signed-off-by: Krzysztof Kozlowski Signed-off-by: Sasha Levin --- diff --git a/drivers/memory/jz4780-nemc.c b/drivers/memory/jz4780-nemc.c index 3ec5cb0..465ea92 100644 --- a/drivers/memory/jz4780-nemc.c +++ b/drivers/memory/jz4780-nemc.c @@ -291,6 +291,8 @@ static int jz4780_nemc_probe(struct platform_device *pdev) nemc->dev = dev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -EINVAL; /* * The driver currently only uses the registers up to offset