memory: jz4780_nemc: Fix potential NULL dereference in jz4780_nemc_probe()
authorZhang Changzhong <zhangchangzhong@huawei.com>
Fri, 4 Dec 2020 08:31:57 +0000 (16:31 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 30 Dec 2020 10:53:37 +0000 (11:53 +0100)
commitd7af811f2e745ecd3495b21f80e3cb007ef54af4
treec199926eada2c2e29a157c961900d235a956dbe8
parent20d79c2a54155dbcc338f799788a305a9d190976
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 <zhangchangzhong@huawei.com>
Acked-by: Paul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/1607070717-32880-1-git-send-email-zhangchangzhong@huawei.com
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/memory/jz4780-nemc.c