linux/drivers/leds
Milo Kim d1aa577f5e leds: turn off the LED and wait for completion on unregistering LED class device
Workqueue, 'set_brightness_work' is used for scheduling brightness control.
This workqueue is canceled when the LED class device is unregistered.
Currently, LED subsystem handles like below.

  cancel_work_sync(&led_cdev->set_brightness_work)
  led_set_brightness(led_cdev, LED_OFF)

However, this could be a problem.
Workqueue is going to be canceled but LED device needs to be off.
The worst case is null pointer access due to scheduling a workqueue.

LED module is loaded.
  LED driver private data is allocated by using devm_zalloc().

LED module is unloaded.
  led_classdev_unregister() is called.
    cancel_work_sync()
      led_set_brightness(led_cdev, LED_OFF)
        schedule_work() if LED driver uses brightness_set_blocking()
        In the meantime, driver private data will be freed.

        ..scheduling..

        brightness_set_blocking() callback is invoked.
          For the brightness control, LED driver tries to access private
          data but resource is removed!

To avoid this problem, LED subsystem should turn off the brightness first
and wait for completion.

  led_set_brightness(led_cdev, LED_OFF)
  flush_work(&led_cdev->set_brightness_work)

It guarantees that LED driver turns off the brightness prior to
resource management.

Cc: linux-leds@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Milo Kim <milo.kim@ti.com>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
2016-01-04 09:57:37 +01:00
..
trigger leds: triggers: oneshot: fix module license specification 2016-01-04 09:57:36 +01:00
dell-led.c dell-led: add mic mute led interface 2014-05-08 14:28:07 +08:00
Kconfig LED/MIPS: Move SEAD3 LED driver to where it belongs. 2015-11-03 08:59:20 +01:00
led-class-flash.c leds: flash: Remove checking for state < 1 in flash_strobe_store() 2016-01-04 09:57:37 +01:00
led-class.c leds: turn off the LED and wait for completion on unregistering LED class device 2016-01-04 09:57:37 +01:00
led-core.c leds: core: Drivers shouldn't enforce SYNC/ASYNC brightness setting 2016-01-04 09:57:31 +01:00
led-triggers.c leds: implement sysfs interface locking mechanism 2014-11-14 14:29:35 -08:00
leds-88pm860x.c leds: 88pm860x: Remove work queue 2016-01-04 09:57:32 +01:00
leds-aat1290.c leds: aat1290: Remove work queue 2016-01-04 09:57:31 +01:00
leds-adp5520.c leds: adp5520: Remove work queue 2016-01-04 09:57:32 +01:00
leds-asic3.c leds: drop owner assignment from platform_drivers 2014-10-20 16:20:43 +02:00
leds-bcm6328.c leds: bcm6328: add missing of_node_put 2015-11-03 09:00:04 +01:00
leds-bcm6358.c leds: bcm6358: add missing of_node_put 2015-11-03 09:00:02 +01:00
leds-bd2802.c leds: bd2802: Remove work queue 2016-01-04 09:57:32 +01:00
leds-blinkm.c leds: blinkm: Remove work queue 2016-01-04 09:57:32 +01:00
leds-clevo-mail.c leds: drop owner assignment from platform_drivers 2014-10-20 16:20:43 +02:00
leds-cobalt-qube.c leds: leds-cobalt-qube: Use devm_led_classdev_register 2015-11-03 08:59:09 +01:00
leds-cobalt-raq.c drivers/leds: don't use module_init in non-modular leds-cobalt-raq.c 2015-06-22 13:57:09 -07:00
leds-da903x.c leds: da903x: Remove work queue 2016-01-04 09:57:34 +01:00
leds-da9052.c leds: da9052: Remove work queue 2016-01-04 09:57:34 +01:00
leds-dac124s085.c leds: dac124d085: Remove work queue 2016-01-04 09:57:34 +01:00
leds-fsg.c leds: leds-fsg: Use devm_led_classdev_register 2015-08-28 14:06:23 +02:00
leds-gpio-register.c led: gpio: Fix possible ZERO_SIZE_PTR pointer dereferencing error. 2014-09-29 10:21:01 -07:00
leds-gpio.c leds: gpio: Remove work queue 2016-01-04 09:57:35 +01:00
leds-hp6xx.c leds: leds-hp6xx: Use devm_led_classdev_register 2015-11-03 08:59:11 +01:00
leds-ipaq-micro.c leds: leds-ipaq-micro: Fix coding style issues 2015-11-03 08:59:17 +01:00
leds-ktd2692.c leds: ktd2692: Add missing of_node_put 2016-01-04 09:57:37 +01:00
leds-lm355x.c leds: lm355x: Remove work queue 2016-01-04 09:57:36 +01:00
leds-lm3530.c leds: Drop owner assignment from i2c_driver 2015-08-28 14:06:02 +02:00
leds-lm3533.c leds: lm3533: Remove work queue 2016-01-04 09:57:32 +01:00
leds-lm3642.c leds: lm3642: Remove work queue 2016-01-04 09:57:32 +01:00
leds-locomo.c leds: leds-locomo.c: Use devm_led_classdev_register 2015-11-03 08:59:50 +01:00
leds-lp55xx-common.c leds: lp55xx: Remove work queue 2016-01-04 09:57:33 +01:00
leds-lp55xx-common.h leds: lp55xx: Remove work queue 2016-01-04 09:57:33 +01:00
leds-lp3944.c leds: lp3944: Remove work queue 2016-01-04 09:57:33 +01:00
leds-lp5521.c leds: lp55xx: Remove work queue 2016-01-04 09:57:33 +01:00
leds-lp5523.c leds: lp55xx: Remove work queue 2016-01-04 09:57:33 +01:00
leds-lp5562.c leds: lp55xx: Remove work queue 2016-01-04 09:57:33 +01:00
leds-lp8501.c leds: lp55xx: Remove work queue 2016-01-04 09:57:33 +01:00
leds-lp8788.c leds: lp8788: Remove work queue 2016-01-04 09:57:33 +01:00
leds-lp8860.c leds: lp8860: Remove work queue 2016-01-04 09:57:33 +01:00
leds-lt3593.c leds: lt3593: Remove work queue 2016-01-04 09:57:34 +01:00
leds-max8997.c leds: max8997: Remove unneeded workqueue include 2016-01-04 09:57:35 +01:00
leds-max77693.c leds: max77693: Remove work queue 2016-01-04 09:57:31 +01:00
leds-mc13783.c leds: mc13783: Remove work queue 2016-01-04 09:57:35 +01:00
leds-menf21bmc.c leds: leds-menf21bmc.c: Use devm_led_class_register 2015-11-03 08:59:52 +01:00
leds-net48xx.c leds: leds-net48xx: Use devm_led_classdev_register 2015-11-03 08:59:54 +01:00
leds-netxbig.c leds: netxbig: set led_classdev max_brightness 2015-11-03 08:59:36 +01:00
leds-ns2.c leds: leds-ns2: Fix module autoload for OF platform driver 2015-09-17 10:02:05 +02:00
leds-ot200.c leds: leds-ot200: Use devm_led_classdev_register 2015-11-03 08:59:13 +01:00
leds-pca955x.c leds: pca955x: Remove work queue 2016-01-04 09:57:33 +01:00
leds-pca963x.c leds: pca963x: Remove work queue 2016-01-04 09:57:34 +01:00
leds-pca9532.c leds: pca9532: Remove work queue for LEDs. 2016-01-04 09:57:33 +01:00
leds-powernv.c powerpc/powernv: add missing of_node_put 2015-11-03 09:00:00 +01:00
leds-pwm.c leds: call led_pwm_set() in leds-pwm to enforce default LED_OFF 2016-01-04 09:57:36 +01:00
leds-rb532.c leds: drop owner assignment from platform_drivers 2014-10-20 16:20:43 +02:00
leds-regulator.c leds: regulator: Remove work queue 2016-01-04 09:57:35 +01:00
leds-s3c24xx.c leds: drop owner assignment from platform_drivers 2014-10-20 16:20:43 +02:00
leds-sead3.c LED/MIPS: Move SEAD3 LED driver to where it belongs. 2015-11-03 08:59:20 +01:00
leds-ss4200.c leds: ss4200: fix attribute-creation race 2014-06-25 15:34:24 -07:00
leds-sunfire.c leds: drop owner assignment from platform_drivers 2014-10-20 16:20:43 +02:00
leds-syscon.c leds: syscon: Correct check for syscon_node_to_regmap() errors 2015-08-28 14:06:25 +02:00
leds-tca6507.c leds: Export OF module alias information in missing drivers 2015-08-28 14:06:30 +02:00
leds-tlc591xx.c leds: tlc591xx: Remove work queue 2016-01-04 09:57:32 +01:00
leds-versatile.c ARM/leds: move ARM Versatile LED driver to leds subsystem 2014-03-28 10:54:15 +01:00
leds-wm831x-status.c leds: wm831x: Remove work queue 2016-01-04 09:57:34 +01:00
leds-wm8350.c leds: wm8350: Remove work queue 2016-01-04 09:57:35 +01:00
leds-wrap.c leds: leds-wrap.c: Use devm_led_classdev_register 2015-11-03 08:59:58 +01:00
leds.h leds: core: Drivers shouldn't enforce SYNC/ASYNC brightness setting 2016-01-04 09:57:31 +01:00
Makefile LED/MIPS: Move SEAD3 LED driver to where it belongs. 2015-11-03 08:59:20 +01:00