OSDN Git Service

gpio: xgene: Prevent NULL pointer dereference
authorAxel Lin <axel.lin@ingics.com>
Mon, 21 Mar 2016 12:03:50 +0000 (20:03 +0800)
committerLinus Walleij <linus.walleij@linaro.org>
Wed, 30 Mar 2016 08:39:39 +0000 (10:39 +0200)
platform_get_resource() can return NULL, thus add NULL test to prevent NULL
pointer dereference.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-xgene.c

index c0aa387..0dc9161 100644 (file)
@@ -173,6 +173,11 @@ static int xgene_gpio_probe(struct platform_device *pdev)
        }
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (!res) {
+               err = -EINVAL;
+               goto err;
+       }
+
        gpio->base = devm_ioremap_nocache(&pdev->dev, res->start,
                                                        resource_size(res));
        if (!gpio->base) {