diff options
author | Kim, Milo <Milo.Kim@ti.com> | 2013-03-14 20:19:36 -0400 |
---|---|---|
committer | Bryan Wu <cooloney@gmail.com> | 2013-04-01 14:04:50 -0400 |
commit | 24d321284745cbc593fba8115585329d48703704 (patch) | |
tree | e8c266b2b30024980e353ee26086318e02c73f22 /drivers/leds/leds-lp55xx-common.c | |
parent | 313bf0b1a0eaeaac17ea8c4b748f16e28fce8b7a (diff) |
leds: lp55xx: fix the sysfs read operation
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>
Diffstat (limited to 'drivers/leds/leds-lp55xx-common.c')
-rw-r--r-- | drivers/leds/leds-lp55xx-common.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c index 8a388a4afed7..715a6027316f 100644 --- a/drivers/leds/leds-lp55xx-common.c +++ b/drivers/leds/leds-lp55xx-common.c | |||
@@ -80,7 +80,7 @@ static ssize_t lp55xx_show_current(struct device *dev, | |||
80 | { | 80 | { |
81 | struct lp55xx_led *led = dev_to_lp55xx_led(dev); | 81 | struct lp55xx_led *led = dev_to_lp55xx_led(dev); |
82 | 82 | ||
83 | return sprintf(buf, "%d\n", led->led_current); | 83 | return scnprintf(buf, PAGE_SIZE, "%d\n", led->led_current); |
84 | } | 84 | } |
85 | 85 | ||
86 | static ssize_t lp55xx_store_current(struct device *dev, | 86 | static ssize_t lp55xx_store_current(struct device *dev, |
@@ -113,7 +113,7 @@ static ssize_t lp55xx_show_max_current(struct device *dev, | |||
113 | { | 113 | { |
114 | struct lp55xx_led *led = dev_to_lp55xx_led(dev); | 114 | struct lp55xx_led *led = dev_to_lp55xx_led(dev); |
115 | 115 | ||
116 | return sprintf(buf, "%d\n", led->max_current); | 116 | return scnprintf(buf, PAGE_SIZE, "%d\n", led->max_current); |
117 | } | 117 | } |
118 | 118 | ||
119 | static DEVICE_ATTR(led_current, S_IRUGO | S_IWUSR, lp55xx_show_current, | 119 | static DEVICE_ATTR(led_current, S_IRUGO | S_IWUSR, lp55xx_show_current, |