Skip to contentSkip to conversation

OMAP: DSS2: OMAPFB: Add null pointer check

PATCH Applied Samreen 2 participants 2 messages Nov 16, 2010 Framebuffer layer

lore
Share & tools
lore

Samreen

author
#0 lore raw

PATCH v2 1/1 OMAP: DSS2: OMAPFB: Add null pointer check

A null pointer check added. And using kstrdup()
instead of kmalloc() & strcpy()

---
Version2:
- Using kstrdup() instead of kmalloc() & strcpy()
- Using ENOMEM as error code instead of EINVAL
- Subject changed appropriately

The link to v1 of patch is:
https://patchwork.kernel.org/patch/319642/

 drivers/video/omap2/omapfb/omapfb-main.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/video/omap2/omapfb/omapfb-main.c +3 -2
index 6a704f1..4fdab8e 100644
@@ -2132,8 +2132,9 @@ static int omapfb_parse_def_modes(struct omapfb2_device *fbdev)
 	char *str, *options, *this_opt;
 	int r = 0;
 
-	str = kmalloc(strlen(def_mode) + 1, GFP_KERNEL);
-	strcpy(str, def_mode);
+	str = kstrdup(def_mode, GFP_KERNEL);
+	if (!str)
+		return -ENOMEM;
 	options = str;
 
 	while (!r && (this_opt = strsep(&options, ",")) != NULL) {
Signature · 1 line
1.5.6.3