]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
leds: lp55xx: fix the sysfs read operation
authorKim, Milo <Milo.Kim@ti.com>
Fri, 15 Mar 2013 00:19:36 +0000 (17:19 -0700)
committerBryan Wu <cooloney@gmail.com>
Mon, 1 Apr 2013 18:04:50 +0000 (11:04 -0700)
According to a sysfs documentation(Documentation/filesystem/sysfs.txt),
scnprintf() should be used in a read operation method.
It guarantees safe buffer size(PAGE_SIZE) which is allocated by the sysfs.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
drivers/leds/leds-lp5521.c
drivers/leds/leds-lp55xx-common.c

index 1001347ba70bdf5eda5661458bd1eb7389441d44..7f10304219ea5ab31cc4c4c4496151945652ffd0 100644 (file)
@@ -360,7 +360,8 @@ static ssize_t lp5521_selftest(struct device *dev,
        mutex_lock(&chip->lock);
        ret = lp5521_run_selftest(chip, buf);
        mutex_unlock(&chip->lock);
-       return sprintf(buf, "%s\n", ret ? "FAIL" : "OK");
+
+       return scnprintf(buf, PAGE_SIZE, "%s\n", ret ? "FAIL" : "OK");
 }
 
 /* device attributes */
index 8a388a4afed7f4aeae64033e9a6b906d4d9151e9..715a6027316f11e98a867637b22120868f33d46f 100644 (file)
@@ -80,7 +80,7 @@ static ssize_t lp55xx_show_current(struct device *dev,
 {
        struct lp55xx_led *led = dev_to_lp55xx_led(dev);
 
-       return sprintf(buf, "%d\n", led->led_current);
+       return scnprintf(buf, PAGE_SIZE, "%d\n", led->led_current);
 }
 
 static ssize_t lp55xx_store_current(struct device *dev,
@@ -113,7 +113,7 @@ static ssize_t lp55xx_show_max_current(struct device *dev,
 {
        struct lp55xx_led *led = dev_to_lp55xx_led(dev);
 
-       return sprintf(buf, "%d\n", led->max_current);
+       return scnprintf(buf, PAGE_SIZE, "%d\n", led->max_current);
 }
 
 static DEVICE_ATTR(led_current, S_IRUGO | S_IWUSR, lp55xx_show_current,