public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH -next] misc: vexpress: Fix potential NULL dereference in vexpress_syscfg_probe()
@ 2018-07-11 13:17 Wei Yongjun
  2018-07-11 15:41 ` Sudeep Holla
  0 siblings, 1 reply; 3+ messages in thread
From: Wei Yongjun @ 2018-07-11 13:17 UTC (permalink / raw)
  To: linux-arm-kernel

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.

@@
expression pdev, res, n, t, e, e1, e2;
@@

res = platform_get_resource(pdev, t, n);
+ if (!res)
+   return -EINVAL;
... when != res == NULL
e = devm_ioremap(e1, res->start, e2);

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/misc/vexpress-syscfg.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/misc/vexpress-syscfg.c b/drivers/misc/vexpress-syscfg.c
index 9eea30f..2d72c93 100644
--- a/drivers/misc/vexpress-syscfg.c
+++ b/drivers/misc/vexpress-syscfg.c
@@ -259,6 +259,8 @@ static int vexpress_syscfg_probe(struct platform_device *pdev)
 	INIT_LIST_HEAD(&syscfg->funcs);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -EINVAL;
 	if (!devm_request_mem_region(&pdev->dev, res->start,
 			resource_size(res), pdev->name))
 		return -EBUSY;

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-07-12  9:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-11 13:17 [PATCH -next] misc: vexpress: Fix potential NULL dereference in vexpress_syscfg_probe() Wei Yongjun
2018-07-11 15:41 ` Sudeep Holla
2018-07-12  9:18   ` Liviu Dudau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox