backlight: catch invalid input

From: Pavel Machek
Date: Fri Nov 21 2008 - 14:14:19 EST



Currently, echo > brightness turns brightness to zero due to
insufficient checking. Add a test to catch that.

Signed-off-by: Pavel Machek <pavel@xxxxxxx>

diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index fab0bc8..5c2e23d 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -86,6 +86,8 @@ static ssize_t backlight_store_power(str
int power = simple_strtoul(buf, &endp, 0);
size_t size = endp - buf;

+ if (!size)
+ return -EINVAL;
if (*endp && isspace(*endp))
size++;
if (size != count)


--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/