leds: triggers: Flush pending brightness before activating trigger
[ Upstream commitab477b766e
] The race fixed in timer_trig_activate() between a blocking set_brightness() call and trigger->activate() can affect any trigger. So move the call to flush_work() into led_trigger_set() where it can avoid the race for all triggers. Fixes:0db37915d9
("leds: avoid races with workqueue") Fixes:8c0f693c6e
("leds: avoid flush_work in atomic context") Cc: stable@vger.kernel.org Tested-by: Dustin L. Howett <dustin@howett.net> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Link: https://lore.kernel.org/r/20240613-led-trigger-flush-v2-1-f4f970799d77@weissschuh.net Signed-off-by: Lee Jones <lee@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
9ce3c14f0d
commit
93ac74cd6f
|
@ -201,6 +201,12 @@ int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
|
|||
*/
|
||||
synchronize_rcu();
|
||||
|
||||
/*
|
||||
* If "set brightness to 0" is pending in workqueue,
|
||||
* we don't want that to be reordered after ->activate()
|
||||
*/
|
||||
flush_work(&led_cdev->set_brightness_work);
|
||||
|
||||
ret = 0;
|
||||
if (trig->activate)
|
||||
ret = trig->activate(led_cdev);
|
||||
|
|
|
@ -110,11 +110,6 @@ static int timer_trig_activate(struct led_classdev *led_cdev)
|
|||
led_cdev->flags &= ~LED_INIT_DEFAULT_TRIGGER;
|
||||
}
|
||||
|
||||
/*
|
||||
* If "set brightness to 0" is pending in workqueue, we don't
|
||||
* want that to be reordered after blink_set()
|
||||
*/
|
||||
flush_work(&led_cdev->set_brightness_work);
|
||||
led_blink_set(led_cdev, &led_cdev->blink_delay_on,
|
||||
&led_cdev->blink_delay_off);
|
||||
|
||||
|
|
Loading…
Reference in New Issue