[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200401030017.100274-1-chenzhou10@huawei.com>
Date: Wed, 1 Apr 2020 11:00:17 +0800
From: Chen Zhou <chenzhou10@...wei.com>
To: <rmfrfs@...il.com>, <johan@...nel.org>, <elder@...nel.org>,
<gregkh@...uxfoundation.org>
CC: <chenzhou10@...wei.com>, <greybus-dev@...ts.linaro.org>,
<devel@...verdev.osuosl.org>, <linux-kernel@...r.kernel.org>
Subject: [PATCH -next] staging: greybus: fix a missing-check bug in gb_lights_light_config()
In gb_lights_light_config(), 'light->name' is allocated by kstrndup().
It returns NULL when fails, add check for it.
Signed-off-by: Chen Zhou <chenzhou10@...wei.com>
---
drivers/staging/greybus/light.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c
index d6ba25f..d2672b6 100644
--- a/drivers/staging/greybus/light.c
+++ b/drivers/staging/greybus/light.c
@@ -1026,7 +1026,8 @@ 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(struct gb_channel), GFP_KERNEL);
if (!light->channels)
--
2.7.4
Powered by blists - more mailing lists