Skip to content

Commit c29e9da

Browse files
Wei YongjunLinus Walleij
authored andcommitted
pinctrl: nsp: Fix potential NULL dereference
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_nocache(e1, res->start, e2); Fixes: cc4fa83 ("pinctrl: nsp: add pinmux driver support for Broadcom NSP SoC") Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com> Reviewed-by: Ray Jui <ray.jui@broadcom.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent f90a21c commit c29e9da

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

‎drivers/pinctrl/bcm/pinctrl-nsp-mux.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,8 @@ static int nsp_pinmux_probe(struct platform_device *pdev)
577577
return PTR_ERR(pinctrl->base0);
578578

579579
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
580+
if (!res)
581+
return -EINVAL;
580582
pinctrl->base1 = devm_ioremap_nocache(&pdev->dev, res->start,
581583
resource_size(res));
582584
if (!pinctrl->base1) {

0 commit comments

Comments
 (0)