mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-29 13:53:33 +00:00
staging: greybus: fix get_channel_from_mode() failure path
[ Upstream commit34164202a5
] The get_channel_from_mode() function is supposed to return the channel which matches the mode. But it has a bug where if it doesn't find a matching channel then it returns the last channel. It should return NULL instead. Also remove an unnecessary NULL check on "channel". Fixes:2870b52bae
("greybus: lights: add lights implementation") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com> Reviewed-by: Alex Elder <elder@linaro.org> Link: https://lore.kernel.org/r/379c0cb4-39e0-4293-8a18-c7b1298e5420@moroto.mountain Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
e5969c54dd
commit
7fad138dcb
1 changed files with 4 additions and 4 deletions
|
@ -100,15 +100,15 @@ static struct led_classdev *get_channel_cdev(struct gb_channel *channel)
|
||||||
static struct gb_channel *get_channel_from_mode(struct gb_light *light,
|
static struct gb_channel *get_channel_from_mode(struct gb_light *light,
|
||||||
u32 mode)
|
u32 mode)
|
||||||
{
|
{
|
||||||
struct gb_channel *channel = NULL;
|
struct gb_channel *channel;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < light->channels_count; i++) {
|
for (i = 0; i < light->channels_count; i++) {
|
||||||
channel = &light->channels[i];
|
channel = &light->channels[i];
|
||||||
if (channel && channel->mode == mode)
|
if (channel->mode == mode)
|
||||||
break;
|
return channel;
|
||||||
}
|
}
|
||||||
return channel;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __gb_lights_flash_intensity_set(struct gb_channel *channel,
|
static int __gb_lights_flash_intensity_set(struct gb_channel *channel,
|
||||||
|
|
Loading…
Reference in a new issue