gpio: palmas: fix a possible NULL dereference
authorLABBE Corentin <clabbe.montjoie@gmail.com>
Wed, 11 Nov 2015 20:27:36 +0000 (21:27 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 17 Nov 2015 13:40:24 +0000 (14:40 +0100)
of_match_device could return NULL, and so cause a NULL pointer
dereference later.

Reported-by: coverity (CID 1130700)
Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-palmas.c

index 171a6389f9ce086ffdf74f6c50523a77e205b473..52b447c071cbaa2e160bf5a67fc511ae26d6a55d 100644 (file)
@@ -167,6 +167,8 @@ static int palmas_gpio_probe(struct platform_device *pdev)
        const struct palmas_device_data *dev_data;
 
        match = of_match_device(of_palmas_gpio_match, &pdev->dev);
+       if (!match)
+               return -ENODEV;
        dev_data = match->data;
        if (!dev_data)
                dev_data = &palmas_dev_data;