drm/exynos: Fix potential NULL pointer dereference
authorSachin Kamat <sachin.kamat@linaro.org>
Tue, 18 Sep 2012 10:21:30 +0000 (15:51 +0530)
committerInki Dae <inki.dae@samsung.com>
Thu, 4 Oct 2012 01:06:01 +0000 (10:06 +0900)
drm_mode_create() returns NULL if it fails to create
a new display mode. Check the value returned to avoid NULL
pointer deferencing later.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
drivers/gpu/drm/exynos/exynos_drm_connector.c

index 59e79ff4b2eb9ff09528ff03a945e8e326679f4c..87cf3783efdc40fa508f22eef38e9b434b197364 100644 (file)
@@ -150,8 +150,12 @@ static int exynos_drm_connector_get_modes(struct drm_connector *connector)
                count = drm_add_edid_modes(connector, edid);
                kfree(edid);
        } else {
-               struct drm_display_mode *mode = drm_mode_create(connector->dev);
                struct exynos_drm_panel_info *panel;
+               struct drm_display_mode *mode = drm_mode_create(connector->dev);
+               if (!mode) {
+                       DRM_ERROR("failed to create a new display mode.\n");
+                       return 0;
+               }
 
                if (display_ops->get_panel)
                        panel = display_ops->get_panel(manager->dev);