Skip to content

Commit f79b55d

Browse files
Wei Yongjunlinusw
authored andcommitted
gpio: ath79: Fix potential NULL dereference in ath79_gpio_probe()
platform_get_resource() may return NULL, add proper check to avoid potential NULL dereferencing. 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 <[email protected]> [[email protected]: Fixed patch to apply on current tree] Signed-off-by: Alban Bedel <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
1 parent 89b0b4e commit f79b55d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/gpio/gpio-ath79.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ static int ath79_gpio_probe(struct platform_device *pdev)
258258
}
259259

260260
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
261+
if (!res)
262+
return -EINVAL;
261263
ctrl->base = devm_ioremap_nocache(
262264
&pdev->dev, res->start, resource_size(res));
263265
if (!ctrl->base)

0 commit comments

Comments
 (0)