OSDN Git Service

omapfb: Fix potential NULL pointer dereference in kmalloc
authorAditya Pakki <pakki001@umn.edu>
Mon, 1 Apr 2019 15:46:57 +0000 (17:46 +0200)
committerBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Mon, 1 Apr 2019 15:46:57 +0000 (17:46 +0200)
Memory allocated, using kmalloc, for new_compat may fail. This patch
checks for such an error and prevents potential NULL pointer
dereference.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
Cc: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c

index cb6acba..5da7ed6 100644 (file)
@@ -111,6 +111,8 @@ static void __init omapdss_omapify_node(struct device_node *node)
 
        new_len = prop->length + strlen(prefix) * num_strs;
        new_compat = kmalloc(new_len, GFP_KERNEL);
+       if (!new_compat)
+               return;
 
        omapdss_prefix_strcpy(new_compat, new_len, prop->value, prop->length);