Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7bf3a213 authored by Chen Zhou's avatar Chen Zhou Committed by Greg Kroah-Hartman
Browse files

staging: greybus: fix a missing-check bug in gb_lights_light_config()



[ Upstream commit 9bb086e5ba9495ac150fbbcc5c8c2bccc06261dd ]

In gb_lights_light_config(), 'light->name' is allocated by kstrndup().
It returns NULL when fails, add check for it.

Signed-off-by: default avatarChen Zhou <chenzhou10@huawei.com>
Acked-by: default avatarRui Miguel Silva <rmfrfs@gmail.com>
Link: https://lore.kernel.org/r/20200401030017.100274-1-chenzhou10@huawei.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent c970dcc0
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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)