Skip to content

Commit

Permalink
memory: jz4780_nemc: Fix potential NULL dereference in jz4780_nemc_pr…
Browse files Browse the repository at this point in the history
…obe()

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: 911a888 ("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>
  • Loading branch information
Zhang Changzhong authored and Krzysztof Kozlowski committed Dec 5, 2020
1 parent d77d22d commit 4bfa073
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/memory/jz4780-nemc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4bfa073

Please sign in to comment.