diff options
author | Richard Purdie <rpurdie@linux.intel.com> | 2008-10-20 18:16:17 -0400 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2008-10-20 18:21:08 -0400 |
commit | 270c3957dbc5bedf093dc864840be0cc6dbda1f6 (patch) | |
tree | c9caca471a647c3bd58b260ebef9840289533453 /drivers/leds/led-class.c | |
parent | 0266a45896a53b1261e9657aa3fbf9ca3d2fd07b (diff) |
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>
Diffstat (limited to 'drivers/leds/led-class.c')
-rw-r--r-- | drivers/leds/led-class.c | 5 |
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) | |||
110 | if (rc) | 110 | if (rc) |
111 | goto err_out; | 111 | goto err_out; |
112 | 112 | ||
113 | #ifdef CONFIG_LEDS_TRIGGERS | ||
114 | init_rwsem(&led_cdev->trigger_lock); | ||
115 | #endif | ||
113 | /* add to the list of leds */ | 116 | /* add to the list of leds */ |
114 | down_write(&leds_list_lock); | 117 | down_write(&leds_list_lock); |
115 | list_add_tail(&led_cdev->node, &leds_list); | 118 | list_add_tail(&led_cdev->node, &leds_list); |
@@ -118,8 +121,6 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev) | |||
118 | led_update_brightness(led_cdev); | 121 | led_update_brightness(led_cdev); |
119 | 122 | ||
120 | #ifdef CONFIG_LEDS_TRIGGERS | 123 | #ifdef CONFIG_LEDS_TRIGGERS |
121 | init_rwsem(&led_cdev->trigger_lock); | ||
122 | |||
123 | rc = device_create_file(led_cdev->dev, &dev_attr_trigger); | 124 | rc = device_create_file(led_cdev->dev, &dev_attr_trigger); |
124 | if (rc) | 125 | if (rc) |
125 | goto err_out_led_list; | 126 | goto err_out_led_list; |