[PATCH] nv_i2c oops fix
authorAntonino A. Daplas <adaplas@gmail.com>
Wed, 14 Sep 2005 21:19:15 +0000 (14:19 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Wed, 14 Sep 2005 21:34:17 +0000 (14:34 -0700)
The call to fb_firmware_edid may return NULL but this is not checked before
trying to memcpy using this pointer.

Signed-off-by: Antonino Daplas <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/video/nvidia/nv_i2c.c

index ace484fa61ce09fb00512d54d5e7eee2bcfc6a3d..12f2884d3f0bd7da64b6fc37e2042fee4f05f5a6 100644 (file)
@@ -209,10 +209,13 @@ int nvidia_probe_i2c_connector(struct fb_info *info, int conn, u8 **out_edid)
 
        if (!edid && conn == 1) {
                /* try to get from firmware */
-               edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
-               if (edid)
-                       memcpy(edid, fb_firmware_edid(info->device),
-                              EDID_LENGTH);
+               const u8 *e = fb_firmware_edid(info->device);
+
+               if (e != NULL) {
+                       edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
+                       if (edid)
+                               memcpy(edid, e, EDID_LENGTH);
+               }
        }
 
        if (out_edid)