The work which is scheduled by led_classdev->brightness_set() is
potentially left pending or running until after the driver module
is unloaded.

Fix by using resource-controlled version of INIT_WORK().

Signed-off-by: Sven Van Asbroeck <thesve...@googlemail.com>
---
 drivers/input/keyboard/cap11xx.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/input/keyboard/cap11xx.c b/drivers/input/keyboard/cap11xx.c
index 312916f99597..a92dd8ee9ed7 100644
--- a/drivers/input/keyboard/cap11xx.c
+++ b/drivers/input/keyboard/cap11xx.c
@@ -312,7 +312,11 @@ static int cap11xx_init_leds(struct device *dev,
                led->reg = reg;
                led->priv = priv;
 
-               INIT_WORK(&led->work, cap11xx_led_work);
+               error = devm_init_work(dev, &led->work, cap11xx_led_work);
+               if (error) {
+                       of_node_put(child);
+                       return error;
+               }
 
                error = devm_led_classdev_register(dev, &led->cdev);
                if (error) {
-- 
2.17.1

Reply via email to