soc: mediatek: PMIC wrap: Fix possible NULL derefrence.
authorshailendra.v@samsung.com <shailendra.v@samsung.com>
Fri, 27 Jan 2017 11:17:48 +0000 (16:47 +0530)
committerMatthias Brugger <matthias.bgg@gmail.com>
Mon, 15 May 2017 08:47:25 +0000 (10:47 +0200)
of_match_device could return NULL, and so can cause a NULL
pointer dereference later.

Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
drivers/soc/mediatek/mtk-pmic-wrap.c

index 285b434..c80a04e 100644 (file)
@@ -1117,6 +1117,11 @@ static int pwrap_probe(struct platform_device *pdev)
        const struct of_device_id *of_slave_id = NULL;
        struct resource *res;
 
+       if (!of_id) {
+               dev_err(&pdev->dev, "Error: No device match found\n");
+               return -ENODEV;
+       }
+
        if (pdev->dev.of_node->child)
                of_slave_id = of_match_node(of_slave_match_tbl,
                                            pdev->dev.of_node->child);