Ensure all backlight drivers zero the properties structure
Subsystems (4)
cover Ensure all backlight drivers zero the properties structure
[Sorry for the RESEND so soon... embarrassingly I got Lee's e-mail address wrong the first time!]
Luca Weiss recently shared a patch to zero the properties structure for lm3630a... and shortly afterwards I realized I should probably scan for a similar class of errors in other drivers.
Results follow in the next four patches (they could all be one patch but for the fact there are different Fixes: tags)!
Daniel Thompson (4):
backlight: da9052: Fully initialize backlight_properties during probe
backlight: lm3639: Fully initialize backlight_properties during probe
backlight: lp8788: Fully initialize backlight_properties during probe
backlight: mp3309c: Fully initialize backlight_properties during probe
drivers/video/backlight/da9052_bl.c | 1 + drivers/video/backlight/lm3639_bl.c | 1 + drivers/video/backlight/lp8788_bl.c | 1 + drivers/video/backlight/mp3309c.c | 1 + 4 files changed, 4 insertions(+)
base-commit: b401b621758e46812da61fa58a67c3fd8d91de0d --
2.43.0
PATCH RESEND 1/4 backlight: da9052: Fully initialize backlight_properties during probe
props is stack allocated and the fields that are not explcitly set by the probe function need to be zeroed or we'll get undefined behaviour (especially so power/blank states)!
--- drivers/video/backlight/da9052_bl.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/backlight/da9052_bl.c +1 -0
@@ -117,6 +117,7 @@ static int da9052_backlight_probe(struct platform_device *pdev) wleds->led_reg =platform_get_device_id (pdev)->driver_data; wleds->state =DA9052_WLEDS_OFF ; +memset (&props,0 ,sizeof (struct backlight_properties )); props.type =BACKLIGHT_RAW ; props.max_brightness =DA9052_MAX_BRIGHTNESS ;
Signature · 1 line
2.43.0
PATCH RESEND 2/4 backlight: lm3639: Fully initialize backlight_properties during probe
In reply to Daniel Thompsonprops is stack allocated and the fields that are not explcitly set by the probe function need to be zeroed or we'll get undefined behaviour (especially so power/blank states)!
--- drivers/video/backlight/lm3639_bl.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/backlight/lm3639_bl.c +1 -0
@@ -338,6 +338,7 @@ static int lm3639_probe(struct i2c_client *client) }/* backlight */ +memset (&props,0 ,sizeof (struct backlight_properties )); props.type =BACKLIGHT_RAW ; props.brightness = pdata->init_brt_led; props.max_brightness = pdata->max_brt_led;
Signature · 1 line
2.43.0
PATCH RESEND 3/4 backlight: lp8788: Fully initialize backlight_properties during probe
In reply to Daniel Thompsonprops is stack allocated and the fields that are not explcitly set by the probe function need to be zeroed or we'll get undefined behaviour (especially so power/blank states)!
--- drivers/video/backlight/lp8788_bl.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/backlight/lp8788_bl.c +1 -0
@@ -191,6 +191,7 @@ static int lp8788_backlight_register(struct lp8788_bl *bl)int init_brt;char *name; +memset (&props,0 ,sizeof (struct backlight_properties )); props.type =BACKLIGHT_PLATFORM ; props.max_brightness =MAX_BRIGHTNESS ;
Signature · 1 line
2.43.0
PATCH RESEND 4/4 backlight: mp3309c: Fully initialize backlight_properties during probe
In reply to Daniel Thompsonprops is stack allocated and, although this driver initializes all the fields that are not "owned" by the framework, we'd still like to ensure it is zeroed to avoid problems from this driver if the fields change.
--- drivers/video/backlight/mp3309c.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/backlight/mp3309c.c +1 -0
@@ -373,6 +373,7 @@ static int mp3309c_probe(struct i2c_client *client) chip->pdata = pdata;/* Backlight properties */ +memset (&props,0 ,sizeof (struct backlight_properties )); props.brightness = pdata->default_brightness; props.max_brightness = pdata->max_brightness; props.scale =BACKLIGHT_SCALE_LINEAR ;
Signature · 1 line
2.43.0
Re: (subset) [PATCH RESEND 4/4] backlight: mp3309c: Fully initialize backlight_properties during probe
Quoted 5 lines · Daniel Thompson
props is stack allocated and, although this driver initializes all the fields that are not "owned" by the framework, we'd still like to ensure it is zeroed to avoid problems from this driver if the fields change.
Applied, thanks!
[4/4] backlight: mp3309c: Fully initialize backlight_properties during probe
commit: 50a2c0aee92699ed47076636b652f9d27a20fbef
--
Lee Jones [李琼斯]
Quoted 6 lines · On Dienstag, 20. Februar 2024 16:35:23 CET Daniel Thompson wrote:
[Sorry for the RESEND so soon... embarrassingly I got Lee's e-mail address wrong the first time!]
Luca Weiss recently shared a patch to zero the properties structure for lm3630a... and shortly afterwards I realized I should probably scan for a similar class of errors in other drivers.
Thanks for fixing the other drivers! Was definitely a fun one to debug :)
Quoted 22 lines
Results follow in the next four patches (they could all be one patch but for the fact there are different Fixes: tags)!
Daniel Thompson (4):
backlight: da9052: Fully initializebacklight_propertiesduring probe
backlight: lm3639: Fully initializebacklight_propertiesduring probe
backlight: lp8788: Fully initializebacklight_propertiesduring probe
backlight: mp3309c: Fully initializebacklight_propertiesduring probedrivers/video/backlight/da9052_bl.c | 1 + drivers/video/backlight/lm3639_bl.c | 1 + drivers/video/backlight/lp8788_bl.c | 1 + drivers/video/backlight/mp3309c.c | 1 + 4 files changed, 4 insertions(+)base-commit:
b401b621758e46812da61fa58a67c3fd8d91de0d--
2.43.0
Lee Jones
maintainerQuoted 5 lines · Daniel Thompson
[Sorry for the RESEND so soon... embarrassingly I got Lee's e-mail address wrong the first time!]
Luca Weiss recently shared a patch to zero the properties structure for lm3630a... and shortly afterwards I realized I should probably scan for
^
Quoted 7 lines
a similar class of errors in other drivers.
Results follow in the next four patches (they could all be one patch but for the fact there are different Fixes: tags)!
Daniel Thompson (4):
backlight: da9052: Fully initializebacklight_propertiesduring probe
^
Quoted 1 line
backlight: lm3639: Fully initialize
backlight_propertiesduring probe
^
Quoted 1 line
backlight: lp8788: Fully initialize
backlight_propertiesduring probe
^
Quoted 1 line
backlight: mp3309c: Fully initialize
backlight_propertiesduring probe
^
I think you may have the wrong locale set mate! :)
Quoted 11 lines
drivers/video/backlight/da9052_bl.c | 1 + drivers/video/backlight/lm3639_bl.c | 1 + drivers/video/backlight/lp8788_bl.c | 1 + drivers/video/backlight/mp3309c.c | 1 + 4 files changed, 4 insertions(+)base-commit:
b401b621758e46812da61fa58a67c3fd8d91de0d--
2.43.0
Signature · 1 line
Lee Jones [李琼斯]
Re: (subset) [PATCH RESEND 0/4] Ensure all backlight drivers zero the properties structure
In reply to Daniel ThompsonQuoted 8 lines · Daniel Thompson
[Sorry for the RESEND so soon... embarrassingly I got Lee's e-mail address wrong the first time!]
Luca Weiss recently shared a patch to zero the properties structure for lm3630a... and shortly afterwards I realized I should probably scan for a similar class of errors in other drivers.
[...]
Applied, thanks!
[1/4] backlight: da9052: Fully initialize backlight_properties during probe
commit: fc159b40e7980e7f78dbaa72dcc4e8f523dbfd92
[2/4] backlight: lm3639: Fully initialize backlight_properties during probe
commit: aeb7ab878e90041776eae839faa117570dbcce93
[3/4] backlight: lp8788: Fully initialize backlight_properties during probe
commit: cd1995b6ac7384149ad755b74e3c3eb25195ab81--
Lee Jones [李琼斯]