pinctrl: palmas: fix a possible NULL dereference
authorLABBE Corentin <clabbe.montjoie@gmail.com>
Tue, 16 Aug 2016 08:36:53 +0000 (10:36 +0200)
committerLinus Walleij <linus.walleij@linaro.org>
Mon, 22 Aug 2016 12:11:00 +0000 (14:11 +0200)
of_match_device could return NULL, and so cause a NULL pointer
dereference later at line 1009:
pinctrl_data = match->data;

For fixing this problem, we use of_device_get_match_data(), this will
simplify the code a little by using a standard function for
getting the match data.

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

index 8edb3f8c72c820eea3814f4defd01a8891ecd442..a30146da7ffdcb6a72513b87d692a49527a5d16c 100644 (file)
@@ -1004,9 +1004,7 @@ static int palmas_pinctrl_probe(struct platform_device *pdev)
        bool enable_dvfs2 = false;
 
        if (pdev->dev.of_node) {
-               const struct of_device_id *match;
-               match = of_match_device(palmas_pinctrl_of_match, &pdev->dev);
-               pinctrl_data = match->data;
+               pinctrl_data = of_device_get_match_data(&pdev->dev);
                enable_dvfs1 = of_property_read_bool(pdev->dev.of_node,
                                        "ti,palmas-enable-dvfs1");
                enable_dvfs2 = of_property_read_bool(pdev->dev.of_node,