* [PATCH] staging: greybus: light: initialize channel lock before registration
@ 2026-08-18 14:20 Runyu Xiao
2026-08-18 18:23 ` Greg Kroah-Hartman
0 siblings, 1 reply; 2+ messages in thread
From: Runyu Xiao @ 2026-08-18 14:20 UTC (permalink / raw)
To: Rui Miguel Silva
Cc: Johan Hovold, Alex Elder, Greg Kroah-Hartman, Kris Huang,
greybus-dev, linux-staging, linux-kernel, stable, Runyu Xiao,
Jianhao Xu
gb_lights_light_register() registers each channel before initializing
light->channels[i].lock. Channel registration exposes the LED class
device and its brightness callback, which later takes this mutex. A
concurrent brightness update can therefore hit an uninitialized lock.
Initialize the channel mutex before registering the channel so the
callback always sees a valid lock.
Fixes: cc43368a3cde ("greybus: lights: Control runtime pm suspend/resume on AP side")
Cc: stable@vger.kernel.org
Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
---
drivers/staging/greybus/light.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c
index 38c233a706c4..056ef6b0276e 100644
--- a/drivers/staging/greybus/light.c
+++ b/drivers/staging/greybus/light.c
@@ -1043,11 +1043,11 @@ static int gb_lights_light_register(struct gb_light *light)
* found.
*/
for (i = 0; i < light->channels_count; i++) {
+ mutex_init(&light->channels[i].lock);
+
ret = gb_lights_channel_register(&light->channels[i]);
if (ret < 0)
return ret;
-
- mutex_init(&light->channels[i].lock);
}
light->ready = true;
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] staging: greybus: light: initialize channel lock before registration
2026-08-18 14:20 [PATCH] staging: greybus: light: initialize channel lock before registration Runyu Xiao
@ 2026-08-18 18:23 ` Greg Kroah-Hartman
0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2026-08-18 18:23 UTC (permalink / raw)
To: Runyu Xiao
Cc: Rui Miguel Silva, Johan Hovold, Alex Elder, Kris Huang,
greybus-dev, linux-staging, linux-kernel, stable, Jianhao Xu
On Tue, Aug 18, 2026 at 10:20:20PM +0800, Runyu Xiao wrote:
> gb_lights_light_register() registers each channel before initializing
> light->channels[i].lock. Channel registration exposes the LED class
> device and its brightness callback, which later takes this mutex. A
> concurrent brightness update can therefore hit an uninitialized lock.
>
> Initialize the channel mutex before registering the channel so the
> callback always sees a valid lock.
>
> Fixes: cc43368a3cde ("greybus: lights: Control runtime pm suspend/resume on AP side")
> Cc: stable@vger.kernel.org
> Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
> ---
> drivers/staging/greybus/light.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c
> index 38c233a706c4..056ef6b0276e 100644
> --- a/drivers/staging/greybus/light.c
> +++ b/drivers/staging/greybus/light.c
> @@ -1043,11 +1043,11 @@ static int gb_lights_light_register(struct gb_light *light)
> * found.
> */
> for (i = 0; i < light->channels_count; i++) {
> + mutex_init(&light->channels[i].lock);
> +
> ret = gb_lights_channel_register(&light->channels[i]);
> if (ret < 0)
> return ret;
> -
> - mutex_init(&light->channels[i].lock);
> }
>
> light->ready = true;
How was this found and tested?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-18 18:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-18 14:20 [PATCH] staging: greybus: light: initialize channel lock before registration Runyu Xiao
2026-08-18 18:23 ` Greg Kroah-Hartman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.