* [PATCH] backlight: lp855x: fix unintialized function return
@ 2023-08-11 13:15 Arnd Bergmann
2023-08-14 8:41 ` Daniel Thompson
0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2023-08-11 13:15 UTC (permalink / raw)
To: Lee Jones, Daniel Thompson, Jingoo Han, Helge Deller, Artur Weber
Cc: Arnd Bergmann, Uwe Kleine-König, Benjamin Mugnier,
Krzysztof Kozlowski, dri-devel, linux-fbdev, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
The function now returns an error code in some cases, but fails to initialize
it in others:
drivers/video/backlight/lp855x_bl.c:252:11: error: variable 'ret' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
else if (lp->mode == REGISTER_BASED)
^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/video/backlight/lp855x_bl.c:256:9: note: uninitialized use occurs here
return ret;
^~~
drivers/video/backlight/lp855x_bl.c:252:7: note: remove the 'if' if its condition is always true
else if (lp->mode == REGISTER_BASED)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Since this case should not actually happen, return the -EINVAL code.
Fixes: 5145531be5fba ("backlight: lp855x: Catch errors when changing brightness")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/video/backlight/lp855x_bl.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c
index 61a7f45bfad84..ea4fa69e49a70 100644
--- a/drivers/video/backlight/lp855x_bl.c
+++ b/drivers/video/backlight/lp855x_bl.c
@@ -252,6 +252,8 @@ static int lp855x_bl_update_status(struct backlight_device *bl)
else if (lp->mode == REGISTER_BASED)
ret = lp855x_write_byte(lp, lp->cfg->reg_brightness,
(u8)brightness);
+ else
+ ret = -EINVAL;
return ret;
}
--
2.39.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] backlight: lp855x: fix unintialized function return
2023-08-11 13:15 [PATCH] backlight: lp855x: fix unintialized function return Arnd Bergmann
@ 2023-08-14 8:41 ` Daniel Thompson
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Thompson @ 2023-08-14 8:41 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Lee Jones, Jingoo Han, Helge Deller, Artur Weber, Arnd Bergmann,
Uwe Kleine-König, Benjamin Mugnier, Krzysztof Kozlowski,
dri-devel, linux-fbdev, linux-kernel
On Fri, Aug 11, 2023 at 03:15:53PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> The function now returns an error code in some cases, but fails to initialize
> it in others:
>
> drivers/video/backlight/lp855x_bl.c:252:11: error: variable 'ret' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
> else if (lp->mode == REGISTER_BASED)
> ^~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/video/backlight/lp855x_bl.c:256:9: note: uninitialized use occurs here
> return ret;
> ^~~
> drivers/video/backlight/lp855x_bl.c:252:7: note: remove the 'if' if its condition is always true
> else if (lp->mode == REGISTER_BASED)
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Since this case should not actually happen, return the -EINVAL code.
>
> Fixes: 5145531be5fba ("backlight: lp855x: Catch errors when changing brightness")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
I think we already received a patch for this:
https://lore.kernel.org/lkml/20230809163825.GA5056@aspen.lan/T/
Daniel.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-08-14 8:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-11 13:15 [PATCH] backlight: lp855x: fix unintialized function return Arnd Bergmann
2023-08-14 8:41 ` Daniel Thompson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox