diff mbox

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

Message ID 1289908147-12468-1-git-send-email-samreen@ti.com (mailing list archive)
State Accepted
Delegated to: Tomi Valkeinen
Headers show

Commit Message

Samreen Nov. 16, 2010, 11:49 a.m. UTC
None
diff mbox

Patch

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) {