leds-lp5523: BUG() in error handling in probe()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 27 Jun 2012 09:10:56 +0000 (17:10 +0800)
committerBryan Wu <bryan.wu@canonical.com>
Mon, 23 Jul 2012 23:52:35 +0000 (07:52 +0800)
Inside the error handling in lp5523_init_led(), there is a place that
calls to led_classdev_unregister().  When we unregister the LED drivers,
it tries to set the brightness to OFF.  In this driver setting the
brightness is done through a work queue and the work queue hasn't been
initialized yet.

The result is that we trigger a WARN_ON() in the __queue_work().

The fix is to move the INIT_WORK() in front of the call to
lp5523_init_led().

Matt Renzelmann found this using a bug finding tool.

Reported-by: Matt Renzelmann <mjr@cs.wisc.edu>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
drivers/leds/leds-lp5523.c

index 857a3e15f2dde8eb8ebc3b90bf30a0c4388b8311..e8a271232cd0f3e60238fd910e5742b411162311 100644 (file)
@@ -943,6 +943,9 @@ static int __devinit lp5523_probe(struct i2c_client *client,
                if (pdata->led_config[i].led_current == 0)
                        continue;
 
+               INIT_WORK(&chip->leds[led].brightness_work,
+                       lp5523_led_brightness_work);
+
                ret = lp5523_init_led(&chip->leds[led], &client->dev, i, pdata);
                if (ret) {
                        dev_err(&client->dev, "error initializing leds\n");
@@ -956,9 +959,6 @@ static int __devinit lp5523_probe(struct i2c_client *client,
                          LP5523_REG_LED_CURRENT_BASE + chip->leds[led].chan_nr,
                          chip->leds[led].led_current);
 
-               INIT_WORK(&(chip->leds[led].brightness_work),
-                       lp5523_led_brightness_work);
-
                led++;
        }