[PATCH v2] OMAP: DSS2: OMAPFB: Add null pointer check

Subsystems: framebuffer layer, the rest

STALE5805d

2 messages, 2 authors, 2010-11-16 · open the first message on its own page

[PATCH v2] OMAP: DSS2: OMAPFB: Add null pointer check

From: Samreen <hidden>
Date: 2010-11-16 11:54:17

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

Signed-off-by: Samreen <redacted>
---
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(-)
diff --git a/drivers/video/omap2/omapfb/omapfb-main.c b/drivers/video/omap2/omapfb/omapfb-main.c
index 6a704f1..4fdab8e 100644
--- a/drivers/video/omap2/omapfb/omapfb-main.c
+++ b/drivers/video/omap2/omapfb/omapfb-main.c
@@ -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) {
-- 
1.5.6.3

Re: [PATCH v2] OMAP: DSS2: OMAPFB: Add null pointer check

From: Tomi Valkeinen <hidden>
Date: 2010-11-16 13:36:41

On Tue, 2010-11-16 at 12:49 +0100, ext Samreen wrote:
A null pointer check added. And using kstrdup()
instead of kmalloc() & strcpy()

Signed-off-by: Samreen <redacted>
---
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/
Thanks, applied.

 Tomi

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help