Locking in LED core really not needed or missing?
I'm a little puzzled about the more or less completely missing locking in the LED core.
Let's just take led_timer_function as example.
It modifies led_cdev->flags and led_cdev->brightness from soft irq context (soft blink timer) w/o locking. Accessing these fields is not guaranteed to be atomic and the function doesn't even use set_bit etc. for modifying the bitmap.
And brightness_set and other exported functions can even be called from hard irq context (e.g. by triggers).
This seems to be quite unsafe to me. Just think of a soft or hard irq colliding with a sysfs access. IMHO it's just due to the fact that these collision scenarios are relatively unlikely that we don't have problems.
Am I missing something or is this actually an open issue?
Hi Heiner,
Quoted 9 lines · Heiner Kallweit
I'm a little puzzled about the more or less completely missing locking in the LED core.
Let's just take
led_timer_functionas example.
It modifiesled_cdev->flagsandled_cdev->brightnessfrom soft irq context (soft blink timer) w/o locking. Accessing these fields is not guaranteed to be atomic and the function doesn't even useset_bitetc. for modifying the bitmap.And
brightness_setand other exported functions can even be called from hard irq context (e.g. by triggers).
led_set_brightness() behaves differently when blink timer is enabled. This issue was initially addressed by the patch [1]. Currently even more related improvements sit on linux-next.
Quoted 9 lines
This seems to be quite unsafe to me. Just think of a soft or hard irq colliding with a sysfs access. IMHO it's just due to the fact that these collision scenarios are relatively unlikely that we don't have problems.
Am I missing something or is this actually an open issue?
--
To unsubscribe from this list: send the line "unsubscribe linux-leds" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
[1] http://www.spinics.net/lists/linux-leds/msg00006.html
Signature · 2 lines
Best Regards, Jacek Anaszewski