]> git.itanic.dy.fi Git - linux-stable/commit
staging: greybus: fix get_channel_from_mode() failure path
authorDan Carpenter <dan.carpenter@linaro.org>
Mon, 4 Mar 2024 07:04:48 +0000 (10:04 +0300)
committerSasha Levin <sashal@kernel.org>
Tue, 26 Mar 2024 22:17:30 +0000 (18:17 -0400)
commit7fad138dcb4296053ac26822404d35df7991ddd1
treee482eb425d9d50d3a1e211d7fd310f11f9a357f8
parente5969c54dd353714de2575d849a34d9f66395e02
staging: greybus: fix get_channel_from_mode() failure path

[ Upstream commit 34164202a5827f60a203ca9acaf2d9f7d432aac8 ]

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: 2870b52bae4c ("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>
drivers/staging/greybus/light.c