Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 24d32128 authored by Kim, Milo's avatar Kim, Milo Committed by Bryan Wu
Browse files

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: default avatarMilo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: default avatarBryan Wu <cooloney@gmail.com>
parent 313bf0b1
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -360,7 +360,8 @@ static ssize_t lp5521_selftest(struct device *dev,
	mutex_lock(&chip->lock);
	mutex_lock(&chip->lock);
	ret = lp5521_run_selftest(chip, buf);
	ret = lp5521_run_selftest(chip, buf);
	mutex_unlock(&chip->lock);
	mutex_unlock(&chip->lock);
	return sprintf(buf, "%s\n", ret ? "FAIL" : "OK");

	return scnprintf(buf, PAGE_SIZE, "%s\n", ret ? "FAIL" : "OK");
}
}


/* device attributes */
/* device attributes */
+2 −2
Original line number Original line Diff line number Diff line
@@ -80,7 +80,7 @@ static ssize_t lp55xx_show_current(struct device *dev,
{
{
	struct lp55xx_led *led = dev_to_lp55xx_led(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,
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);
	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,
static DEVICE_ATTR(led_current, S_IRUGO | S_IWUSR, lp55xx_show_current,