[PATCH] LED: Fix sysfs store function error handling

Fix the error handling of some LED _store functions.  This corrects them to
return -EINVAL if the value is not numeric with an optional byte of trailing
whitespace.

Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Richard Purdie
2006-05-15 09:44:17 -07:00
committed by Linus Torvalds
parent 263de9b582
commit 3dc7b82ea7
2 changed files with 20 additions and 6 deletions

View File

@@ -19,6 +19,7 @@
#include <linux/sysdev.h>
#include <linux/timer.h>
#include <linux/err.h>
#include <linux/ctype.h>
#include <linux/leds.h>
#include "leds.h"
@@ -43,9 +44,13 @@ static ssize_t led_brightness_store(struct class_device *dev,
ssize_t ret = -EINVAL;
char *after;
unsigned long state = simple_strtoul(buf, &after, 10);
size_t count = after - buf;
if (after - buf > 0) {
ret = after - buf;
if (*after && isspace(*after))
count++;
if (count == size) {
ret = count;
led_set_brightness(led_cdev, state);
}