summaryrefslogtreecommitdiff
path: root/drivers/leds/ledtrig-timer.c
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2006-10-17 11:10:20 +0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-17 19:18:46 +0400
commit12fda16814bba05a84a49a1da25a069d6c249758 (patch)
tree05cb63f14784190d75e98d6ac3f9b2e5949a5539 /drivers/leds/ledtrig-timer.c
parent58ff407bee5a55f9c1188a3f9d70ffc79485183c (diff)
downloadlinux-12fda16814bba05a84a49a1da25a069d6c249758.tar.xz
[PATCH] drivers/led: handle sysfs errors
Signed-off-by: Jeff Garzik <jeff@garzik.org> Cc: Richard Purdie <rpurdie@rpsys.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/leds/ledtrig-timer.c')
-rw-r--r--drivers/leds/ledtrig-timer.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/leds/ledtrig-timer.c b/drivers/leds/ledtrig-timer.c
index 179c2876b541..29a8818a32ec 100644
--- a/drivers/leds/ledtrig-timer.c
+++ b/drivers/leds/ledtrig-timer.c
@@ -123,6 +123,7 @@ static CLASS_DEVICE_ATTR(delay_off, 0644, led_delay_off_show,
static void timer_trig_activate(struct led_classdev *led_cdev)
{
struct timer_trig_data *timer_data;
+ int rc;
timer_data = kzalloc(sizeof(struct timer_trig_data), GFP_KERNEL);
if (!timer_data)
@@ -134,10 +135,21 @@ static void timer_trig_activate(struct led_classdev *led_cdev)
timer_data->timer.function = led_timer_function;
timer_data->timer.data = (unsigned long) led_cdev;
- class_device_create_file(led_cdev->class_dev,
+ rc = class_device_create_file(led_cdev->class_dev,
&class_device_attr_delay_on);
- class_device_create_file(led_cdev->class_dev,
+ if (rc) goto err_out;
+ rc = class_device_create_file(led_cdev->class_dev,
&class_device_attr_delay_off);
+ if (rc) goto err_out_delayon;
+
+ return;
+
+err_out_delayon:
+ class_device_remove_file(led_cdev->class_dev,
+ &class_device_attr_delay_on);
+err_out:
+ led_cdev->trigger_data = NULL;
+ kfree(timer_data);
}
static void timer_trig_deactivate(struct led_classdev *led_cdev)