diff mbox series

omapfb: Fix potential NULL pointer dereference in kmalloc

Message ID 20190302204006.9953-1-pakki001@umn.edu (mailing list archive)
State New, archived
Headers show
Series omapfb: Fix potential NULL pointer dereference in kmalloc | expand

Commit Message

Aditya Pakki March 2, 2019, 8:40 p.m. UTC
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>
---
 drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Bartlomiej Zolnierkiewicz April 1, 2019, 1:01 p.m. UTC | #1
On 03/02/2019 09:40 PM, Aditya Pakki wrote:
> 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>

Patch queued for v5.2, thanks.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
diff mbox series

Patch

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 136d30484d02..0592c436b2da 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);