Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

OMAPFB: fix error handling in omapfb_find_best_mode()

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>

+6
+6
drivers/video/omap2/omapfb/omapfb-main.c
··· 2241 2241 2242 2242 len = 0x80 * 2; 2243 2243 edid = kmalloc(len, GFP_KERNEL); 2244 + if (edid == NULL) 2245 + return -ENOMEM; 2244 2246 2245 2247 r = display->driver->read_edid(display, edid, len); 2246 2248 if (r < 0) 2247 2249 goto err1; 2248 2250 2249 2251 specs = kzalloc(sizeof(*specs), GFP_KERNEL); 2252 + if (specs == NULL) { 2253 + r = -ENOMEM; 2254 + goto err1; 2255 + } 2250 2256 2251 2257 fb_edid_to_monspecs(edid, specs); 2252 2258