mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
staging: greybus: fix a missing-check bug in gb_lights_light_config()
[ Upstream commit 9bb086e5ba ]
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@huawei.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Link: https://lore.kernel.org/r/20200401030017.100274-1-chenzhou10@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
d85760a6b0
commit
d485ba3c8f
@@ -1028,7 +1028,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)
|
||||
|
||||
Reference in New Issue
Block a user