[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f6479c52-4dd1-fec4-f659-2fe64d5024fd@users.sourceforge.net>
Date: Fri, 9 Dec 2016 15:37:56 +0100
From: SF Markus Elfring <elfring@...rs.sourceforge.net>
To: devel@...verdev.osuosl.org, Alex Elder <elder@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Johan Hovold <johan@...nel.org>,
Rui Miguel Silva <rmfrfs@...il.com>
Cc: LKML <linux-kernel@...r.kernel.org>,
kernel-janitors@...r.kernel.org
Subject: [PATCH 3/4] staging: greybus: light: Check return value of a
kstrndup() call in gb_lights_light_config()
From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Fri, 9 Dec 2016 14:36:16 +0100
A return value was not checked after a call of the function "kstrndup".
This issue was detected by using the Coccinelle software.
Add a bit of exception handling.
Fixes: 2870b52bae4c81823ffcb3ed2b0626fb39d64f48 ("greybus: lights: add lights implementation")
Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
drivers/staging/greybus/light.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c
index 27bfc20eb9a5..c9c377f40f56 100644
--- a/drivers/staging/greybus/light.c
+++ b/drivers/staging/greybus/light.c
@@ -1030,6 +1030,9 @@ static int gb_lights_light_config(struct gb_lights *glights, u8 id)
light->channels_count = conf.channel_count;
light->name = kstrndup(conf.name, NAMES_MAX, GFP_KERNEL);
+ if (!light->name)
+ return -ENOMEM;
+
light->channels = kcalloc(light->channels_count,
sizeof(*light->channels),
GFP_KERNEL);
--
2.11.0
Powered by blists - more mailing lists