From: SF Markus Elfring Date: Fri, 09 Dec 2016 14:37:56 +0000 Subject: [PATCH 3/4] staging: greybus: light: Check return value of a kstrndup() call in gb_lights_light_conf Message-Id: List-Id: References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: devel@driverdev.osuosl.org, Alex Elder , Greg Kroah-Hartman , Johan Hovold , Rui Miguel Silva Cc: LKML , kernel-janitors@vger.kernel.org From: Markus Elfring 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 --- 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