summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2008-10-21 02:16:17 +0400
committerRichard Purdie <rpurdie@linux.intel.com>2008-10-21 02:21:08 +0400
commit270c3957dbc5bedf093dc864840be0cc6dbda1f6 (patch)
treec9caca471a647c3bd58b260ebef9840289533453
parent0266a45896a53b1261e9657aa3fbf9ca3d2fd07b (diff)
downloadlinux-270c3957dbc5bedf093dc864840be0cc6dbda1f6.tar.xz
leds: Fix trigger registration race
Fix a race during trigger registration where we could try and use a lock before it was initialised. Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
-rw-r--r--drivers/leds/led-class.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index 5db86c29fe61..6c4a326176d7 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -110,6 +110,9 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
if (rc)
goto err_out;
+#ifdef CONFIG_LEDS_TRIGGERS
+ init_rwsem(&led_cdev->trigger_lock);
+#endif
/* add to the list of leds */
down_write(&leds_list_lock);
list_add_tail(&led_cdev->node, &leds_list);
@@ -118,8 +121,6 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
led_update_brightness(led_cdev);
#ifdef CONFIG_LEDS_TRIGGERS
- init_rwsem(&led_cdev->trigger_lock);
-
rc = device_create_file(led_cdev->dev, &dev_attr_trigger);
if (rc)
goto err_out_led_list;