pinctrl: ns2: Fix potential NULL dereference
authorYoung Xiao <92siuyang@gmail.com>
Wed, 29 May 2019 02:43:58 +0000 (10:43 +0800)
committerLinus Walleij <linus.walleij@linaro.org>
Fri, 7 Jun 2019 23:29:42 +0000 (01:29 +0200)
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.

Signed-off-by: Young Xiao <92siuyang@gmail.com>
Reviewed-by: Ray Jui <ray.jui@broadcom.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/bcm/pinctrl-ns2-mux.c

index 4b5cf0e..2bf6af7 100644 (file)
@@ -1048,6 +1048,8 @@ static int ns2_pinmux_probe(struct platform_device *pdev)
                return PTR_ERR(pinctrl->base0);
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+       if (!res)
+               return -EINVAL;
        pinctrl->base1 = devm_ioremap_nocache(&pdev->dev, res->start,
                                        resource_size(res));
        if (!pinctrl->base1) {