]> git.karo-electronics.de Git - karo-tx-linux.git/commit
leds: leds-pwm: properly clean up after probe failure
authorRussell King <rmk+kernel@arm.linux.org.uk>
Sun, 6 Apr 2014 22:20:03 +0000 (15:20 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 7 Jun 2014 17:28:18 +0000 (10:28 -0700)
commit7a5db34ad2ea9a97448904a8a9e6e49d82e9d133
tree55e9f9eb1e7a5dc3a0d4a9e2fd2ed7c0dcd71a79
parent92840945e295889bde76fb38531f11dafb34b506
leds: leds-pwm: properly clean up after probe failure

commit 392369019eb96e914234ea21eda806cb51a1073e upstream.

When probing with DT, we add each LED one at a time.  If we find a LED
without a PWM device (because it is not available yet) we fail the
initialisation, unregister previous LEDs, and then by way of managed
resources, we free the structure.

The problem with this is we may have a scheduled and active work_struct
in this structure, and this results in a nasty kernel oops.

We need to cancel this work_struct properly upon cleanup - and the
cleanup we require is the same cleanup as we do when the LED platform
device is removed.  Rather than writing this same code three times,
move it into a separate function and use it in all three places.

Fixes: c971ff185f64 ("leds: leds-pwm: Defer led_pwm_set() if PWM can sleep")
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/leds/leds-pwm.c