From: Aditya Pakki Date: Mon, 1 Apr 2019 15:46:57 +0000 (+0200) Subject: omapfb: Fix potential NULL pointer dereference in kmalloc X-Git-Tag: v5.15~6020^2~52 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=31fa6e2ae65feed0de10823c5d1eea21a93086c9;p=platform%2Fkernel%2Flinux-starfive.git omapfb: Fix potential NULL pointer dereference in kmalloc 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 Cc: Kangjie Lu Signed-off-by: Bartlomiej Zolnierkiewicz --- diff --git a/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c b/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c index cb6acba..5da7ed6 100644 --- a/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c +++ b/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c @@ -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);