[media] exynos4-is: Fix potential NULL pointer dereference
authorSachin Kamat <sachin.kamat@linaro.org>
Fri, 2 Aug 2013 07:58:25 +0000 (04:58 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Sun, 18 Aug 2013 12:25:00 +0000 (09:25 -0300)
dev->of_node could be NULL. Hence check for the same and return before
dereferencing it in the subsequent error message.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/platform/exynos4-is/fimc-lite.c

index 08fbfedea90fd59e705b244b81442a4515e2403c..318d4c3e3b61683afec5621caa24f2cd63f925ea 100644 (file)
@@ -1504,16 +1504,17 @@ static int fimc_lite_probe(struct platform_device *pdev)
        struct resource *res;
        int ret;
 
+       if (!dev->of_node)
+               return -ENODEV;
+
        fimc = devm_kzalloc(dev, sizeof(*fimc), GFP_KERNEL);
        if (!fimc)
                return -ENOMEM;
 
-       if (dev->of_node) {
-               of_id = of_match_node(flite_of_match, dev->of_node);
-               if (of_id)
-                       drv_data = (struct flite_drvdata *)of_id->data;
-               fimc->index = of_alias_get_id(dev->of_node, "fimc-lite");
-       }
+       of_id = of_match_node(flite_of_match, dev->of_node);
+       if (of_id)
+               drv_data = (struct flite_drvdata *)of_id->data;
+       fimc->index = of_alias_get_id(dev->of_node, "fimc-lite");
 
        if (!drv_data || fimc->index >= drv_data->num_instances ||
                                                fimc->index < 0) {