pinctrl: nomadik: Prevent NULL dereference if of_match_device returns NULL
authorAxel Lin <axel.lin@ingics.com>
Thu, 15 Nov 2012 04:56:05 +0000 (12:56 +0800)
committerLinus Walleij <linus.walleij@linaro.org>
Thu, 15 Nov 2012 15:50:15 +0000 (16:50 +0100)
of_match_device() may return NULL.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/pinctrl-nomadik.c

index 6a95d0438b6ab22026a9dae53b546f95e730c061..98c088ae7f4a3c580accde293302f054707a54fd 100644 (file)
@@ -1864,9 +1864,14 @@ static int __devinit nmk_pinctrl_probe(struct platform_device *pdev)
 
        if (platid)
                version = platid->driver_data;
-       else if (np)
-               version = (unsigned int)
-                       of_match_device(nmk_pinctrl_match, &pdev->dev)->data;
+       else if (np) {
+               const struct of_device_id *match;
+
+               match = of_match_device(nmk_pinctrl_match, &pdev->dev);
+               if (!match)
+                       return -ENODEV;
+               version = (unsigned int) match->data;
+       }
 
        /* Poke in other ASIC variants here */
        if (version == PINCTRL_NMK_STN8815)