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>
This commit is contained in:
Richard Purdie 2008-10-20 23:16:17 +01:00
parent 0266a45896
commit 270c3957db
1 changed files with 3 additions and 2 deletions

View File

@ -110,6 +110,9 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
if (rc) if (rc)
goto err_out; goto err_out;
#ifdef CONFIG_LEDS_TRIGGERS
init_rwsem(&led_cdev->trigger_lock);
#endif
/* add to the list of leds */ /* add to the list of leds */
down_write(&leds_list_lock); down_write(&leds_list_lock);
list_add_tail(&led_cdev->node, &leds_list); 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); led_update_brightness(led_cdev);
#ifdef CONFIG_LEDS_TRIGGERS #ifdef CONFIG_LEDS_TRIGGERS
init_rwsem(&led_cdev->trigger_lock);
rc = device_create_file(led_cdev->dev, &dev_attr_trigger); rc = device_create_file(led_cdev->dev, &dev_attr_trigger);
if (rc) if (rc)
goto err_out_led_list; goto err_out_led_list;