drm/crtc: Fix potential NULL pointer dereference
authorSachin Kamat <sachin.kamat@linaro.org>
Mon, 19 Nov 2012 09:44:57 +0000 (09:44 +0000)
committerDave Airlie <airlied@redhat.com>
Tue, 20 Nov 2012 05:40:51 +0000 (15:40 +1000)
drm_property_create_blob() could return NULL in which case NULL pointer
dereference error (on connector->edid_blob_ptr) is possible. Return if
connector->edid_blob_ptr is NULL.

Fixes the following smatch error:
drivers/gpu/drm/drm_crtc.c:3186 drm_mode_connector_update_edid_property()
error: potential null dereference 'connector->edid_blob_ptr'.
(drm_property_create_blob returns null)

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/drm_crtc.c

index 9fd0c3555c30906ad2a64804c0b8f68497059ed1..6a1b2cc3989819048d0f4dbbc8e0195745effe72 100644 (file)
@@ -3191,6 +3191,8 @@ int drm_mode_connector_update_edid_property(struct drm_connector *connector,
        size = EDID_LENGTH * (1 + edid->extensions);
        connector->edid_blob_ptr = drm_property_create_blob(connector->dev,
                                                            size, edid);
+       if (!connector->edid_blob_ptr)
+               return -EINVAL;
 
        ret = drm_connector_property_set_value(connector,
                                               dev->mode_config.edid_property,