drm/nouveau: use kmemdup for edid allocation/copying
authorMarcin Slusarz <marcin.slusarz@gmail.com>
Sun, 27 Jan 2013 16:04:48 +0000 (17:04 +0100)
committerBen Skeggs <bskeggs@redhat.com>
Wed, 20 Feb 2013 06:00:39 +0000 (16:00 +1000)
Avoids potential null pointer dereference.

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nouveau_connector.c

index e620ba8271b4bc4e5d71edbd8f787a2c14eecf0b..2f3e40ec86a011b66247389e9d848abf50575949 100644 (file)
@@ -399,9 +399,10 @@ nouveau_connector_detect_lvds(struct drm_connector *connector, bool force)
                struct edid *edid =
                        (struct edid *)nouveau_bios_embedded_edid(dev);
                if (edid) {
-                       nv_connector->edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
-                       *(nv_connector->edid) = *edid;
-                       status = connector_status_connected;
+                       nv_connector->edid =
+                                       kmemdup(edid, EDID_LENGTH, GFP_KERNEL);
+                       if (nv_connector->edid)
+                               status = connector_status_connected;
                }
        }