Skip to content

Commit

Permalink
leds: Fix trigger registration race
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Richard Purdie committed Oct 20, 2008
1 parent 0266a45 commit 270c395
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/leds/led-class.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit 270c395

Please sign in to comment.