Skip to content

Commit 67bd8eb

Browse files
jhovoldcooloney
authored andcommitted
leds: ss4200: fix attribute-creation race
Use the attribute groups of the led-class to create the blink attribute during probe in order to avoid racing with userspace. Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Bryan Wu <cooloney@gmail.com>
1 parent 475f854 commit 67bd8eb

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

‎drivers/leds/leds-ss4200.c‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,12 @@ static ssize_t nas_led_blink_store(struct device *dev,
469469

470470
static DEVICE_ATTR(blink, 0644, nas_led_blink_show, nas_led_blink_store);
471471

472+
static struct attribute *nasgpio_led_attrs[] = {
473+
&dev_attr_blink.attr,
474+
NULL
475+
};
476+
ATTRIBUTE_GROUPS(nasgpio_led);
477+
472478
static int register_nasgpio_led(int led_nr)
473479
{
474480
int ret;
@@ -481,20 +487,18 @@ static int register_nasgpio_led(int led_nr)
481487
led->brightness = LED_FULL;
482488
led->brightness_set = nasgpio_led_set_brightness;
483489
led->blink_set = nasgpio_led_set_blink;
490+
led->groups = nasgpio_led_groups;
484491
ret = led_classdev_register(&nas_gpio_pci_dev->dev, led);
485492
if (ret)
486493
return ret;
487-
ret = device_create_file(led->dev, &dev_attr_blink);
488-
if (ret)
489-
led_classdev_unregister(led);
490-
return ret;
494+
495+
return 0;
491496
}
492497

493498
static void unregister_nasgpio_led(int led_nr)
494499
{
495500
struct led_classdev *led = get_classdev_for_led_nr(led_nr);
496501
led_classdev_unregister(led);
497-
device_remove_file(led->dev, &dev_attr_blink);
498502
}
499503
/*
500504
* module load/initialization

0 commit comments

Comments
 (0)