]> Pileus Git - ~andy/linux/commitdiff
OMAPFB: fix error handling in omapfb_find_best_mode()
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Thu, 13 Dec 2012 10:13:51 +0000 (12:13 +0200)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Thu, 13 Dec 2012 10:13:51 +0000 (12:13 +0200)
omapfb_find_best_mode() doesn't check for the return value of kmalloc.
Fix this. This also removes the smatch warning:

drivers/video/omap2/omapfb/omapfb-main.c:2256 omapfb_find_best_mode()
error: potential null dereference 'specs'.  (kzalloc returns null)

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
drivers/video/omap2/omapfb/omapfb-main.c

index 477a20817d084941197f10adfaf18c0de64e33a4..948dfb9f3e9bcc8f4e82599c301d6c5e35cc8c81 100644 (file)
@@ -2241,12 +2241,18 @@ static int omapfb_find_best_mode(struct omap_dss_device *display,
 
        len = 0x80 * 2;
        edid = kmalloc(len, GFP_KERNEL);
+       if (edid == NULL)
+               return -ENOMEM;
 
        r = display->driver->read_edid(display, edid, len);
        if (r < 0)
                goto err1;
 
        specs = kzalloc(sizeof(*specs), GFP_KERNEL);
+       if (specs == NULL) {
+               r = -ENOMEM;
+               goto err1;
+       }
 
        fb_edid_to_monspecs(edid, specs);