* [PATCH v2] backlight: mp3309c: fix uninitialized local variable
@ 2023-11-29 16:45 Flavio Suligoi
2023-11-29 16:53 ` Daniel Thompson
2023-12-01 11:24 ` (subset) " Lee Jones
0 siblings, 2 replies; 3+ messages in thread
From: Flavio Suligoi @ 2023-11-29 16:45 UTC (permalink / raw)
To: Lee Jones, Daniel Thompson, Jingoo Han, Helge Deller,
Dan Carpenter
Cc: dri-devel, linux-fbdev, linux-kernel, Flavio Suligoi
In the function "pm3309c_parse_dt_node", when the dimming analog control
mode (by I2C messages) is enabled, the local variable "prop_levels" is
tested without any initialization, as indicated by the following smatch
warning:
drivers/video/backlight/mp3309c.c:279 pm3309c_parse_dt_node() error: uninitialized symbol 'prop_levels'.
To avoid any problem in case of undefined behavior, we need to initialize
it to "NULL".
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/dri-devel/af0a1870-693b-442f-9b11-0503cfcd944a@moroto.mountain/
Fixes: 2e914516a58c ("backlight: mp3309c: Add support for MPS MP3309C")
Signed-off-by: Flavio Suligoi <f.suligoi@asem.it>
---
v2:
- remove redundant initialization of "prop_pwms" variable
- remove "thanks to Dan Carpenter for the report"
- add "Reported-by: Dan Carpenter <dan.carpenter@linaro.org>" tag
- add "Closes:" tag
drivers/video/backlight/mp3309c.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/video/backlight/mp3309c.c b/drivers/video/backlight/mp3309c.c
index 3fe4469ef43f..34d71259fac1 100644
--- a/drivers/video/backlight/mp3309c.c
+++ b/drivers/video/backlight/mp3309c.c
@@ -203,7 +203,8 @@ static int pm3309c_parse_dt_node(struct mp3309c_chip *chip,
struct mp3309c_platform_data *pdata)
{
struct device_node *node = chip->dev->of_node;
- struct property *prop_pwms, *prop_levels;
+ struct property *prop_pwms;
+ struct property *prop_levels = NULL;
int length = 0;
int ret, i;
unsigned int num_levels, tmp_value;
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] backlight: mp3309c: fix uninitialized local variable
2023-11-29 16:45 [PATCH v2] backlight: mp3309c: fix uninitialized local variable Flavio Suligoi
@ 2023-11-29 16:53 ` Daniel Thompson
2023-12-01 11:24 ` (subset) " Lee Jones
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Thompson @ 2023-11-29 16:53 UTC (permalink / raw)
To: Flavio Suligoi
Cc: Lee Jones, Jingoo Han, Helge Deller, Dan Carpenter, dri-devel,
linux-fbdev, linux-kernel
On Wed, Nov 29, 2023 at 05:45:14PM +0100, Flavio Suligoi wrote:
> In the function "pm3309c_parse_dt_node", when the dimming analog control
> mode (by I2C messages) is enabled, the local variable "prop_levels" is
> tested without any initialization, as indicated by the following smatch
> warning:
>
> drivers/video/backlight/mp3309c.c:279 pm3309c_parse_dt_node() error: uninitialized symbol 'prop_levels'.
>
> To avoid any problem in case of undefined behavior, we need to initialize
> it to "NULL".
>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/dri-devel/af0a1870-693b-442f-9b11-0503cfcd944a@moroto.mountain/
> Fixes: 2e914516a58c ("backlight: mp3309c: Add support for MPS MP3309C")
> Signed-off-by: Flavio Suligoi <f.suligoi@asem.it>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Daniel.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: (subset) [PATCH v2] backlight: mp3309c: fix uninitialized local variable
2023-11-29 16:45 [PATCH v2] backlight: mp3309c: fix uninitialized local variable Flavio Suligoi
2023-11-29 16:53 ` Daniel Thompson
@ 2023-12-01 11:24 ` Lee Jones
1 sibling, 0 replies; 3+ messages in thread
From: Lee Jones @ 2023-12-01 11:24 UTC (permalink / raw)
To: Lee Jones, Daniel Thompson, Jingoo Han, Helge Deller,
Dan Carpenter, Flavio Suligoi
Cc: dri-devel, linux-fbdev, linux-kernel
On Wed, 29 Nov 2023 17:45:14 +0100, Flavio Suligoi wrote:
> In the function "pm3309c_parse_dt_node", when the dimming analog control
> mode (by I2C messages) is enabled, the local variable "prop_levels" is
> tested without any initialization, as indicated by the following smatch
> warning:
>
> drivers/video/backlight/mp3309c.c:279 pm3309c_parse_dt_node() error: uninitialized symbol 'prop_levels'.
>
> [...]
Applied, thanks!
[1/1] backlight: mp3309c: fix uninitialized local variable
commit: ab47505ce45b869ab649024dc932e981fcdd6e5f
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-12-01 11:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-29 16:45 [PATCH v2] backlight: mp3309c: fix uninitialized local variable Flavio Suligoi
2023-11-29 16:53 ` Daniel Thompson
2023-12-01 11:24 ` (subset) " Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox