From: Samreen Date: Tue, 16 Nov 2010 11:49:07 +0000 (+0100) Subject: OMAP: DSS2: OMAPFB: Add null pointer check X-Git-Tag: firefly_0821_release~7613^2~2881^2~10^2~12 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=36e8c27f3bee5e58f96b0a79d65922fa9e53b030;p=firefly-linux-kernel-4.4.55.git OMAP: DSS2: OMAPFB: Add null pointer check A null pointer check added. And using kstrdup() instead of kmalloc() & strcpy() Signed-off-by: Samreen Signed-off-by: Tomi Valkeinen --- diff --git a/drivers/video/omap2/omapfb/omapfb-main.c b/drivers/video/omap2/omapfb/omapfb-main.c index 6a704f176c22..4fdab8e9c496 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) {