mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
leds: class: Always protect brightness_show() with led_access
The led_classdev_register_ext() protects transient states when
registering with the led_access mutex and relies on all sensitive sysfs
attribute callbacks holding the mutex to prevent exposing transient
states.
The Fixes: commit broke this as it accessed trigger_lock without holding
led_access. Fix it by protecting brightness_show() with led_access in
all code paths.
Fixes: b819dc7d8f ("leds: core: Report ENODATA for brightness of hardware controlled LED")
Signed-off-by: Rong Zhang <i@rong.moe>
Link: https://patch.msgid.link/20260921-leds-trigger-hw-changed-v7-1-fe3cdb6dec51@rong.moe
Signed-off-by: Lee Jones <lee@kernel.org>
This commit is contained in:
parent
d494855128
commit
6887f40dad
|
|
@ -43,13 +43,13 @@ static ssize_t brightness_show(struct device *dev,
|
|||
struct led_classdev *led_cdev = dev_get_drvdata(dev);
|
||||
unsigned int brightness;
|
||||
|
||||
if (led_trigger_is_hw_controlled(led_cdev))
|
||||
return -ENODATA;
|
||||
scoped_guard(mutex, &led_cdev->led_access) {
|
||||
if (led_trigger_is_hw_controlled(led_cdev))
|
||||
return -ENODATA;
|
||||
|
||||
mutex_lock(&led_cdev->led_access);
|
||||
led_update_brightness(led_cdev);
|
||||
brightness = led_cdev->brightness;
|
||||
mutex_unlock(&led_cdev->led_access);
|
||||
led_update_brightness(led_cdev);
|
||||
brightness = led_cdev->brightness;
|
||||
}
|
||||
|
||||
return sysfs_emit(buf, "%u\n", brightness);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user