summaryrefslogtreecommitdiffstats
path: root/drivers/leds
diff options
context:
space:
mode:
authorPavel Machek <pavel@ucw.cz>2020-07-24 12:43:47 +0200
committerPavel Machek <pavel@ucw.cz>2020-07-24 12:43:57 +0200
commitfeff72735b316e268da4ccc04091977e8f89a721 (patch)
treec4733e5dab0790595cdead18cfbea8a0f045a937 /drivers/leds
parentleds: Replace HTTP links with HTTPS ones (diff)
downloadlinux-feff72735b316e268da4ccc04091977e8f89a721.tar.xz
linux-feff72735b316e268da4ccc04091977e8f89a721.zip
leds: pattern trigger -- check pattern for validity
Don't allow invalid brightness in the pattern. Signed-off-by: Pavel Machek <pavel@ucw.cz>
Diffstat (limited to 'drivers/leds')
-rw-r--r--drivers/leds/trigger/ledtrig-pattern.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/leds/trigger/ledtrig-pattern.c b/drivers/leds/trigger/ledtrig-pattern.c
index 3abcafe46278..4d138d5317e9 100644
--- a/drivers/leds/trigger/ledtrig-pattern.c
+++ b/drivers/leds/trigger/ledtrig-pattern.c
@@ -227,10 +227,12 @@ static int pattern_trig_store_patterns_string(struct pattern_trig_data *data,
while (offset < count - 1 && data->npatterns < MAX_PATTERNS) {
cr = 0;
- ccount = sscanf(buf + offset, "%d %u %n",
+ ccount = sscanf(buf + offset, "%u %u %n",
&data->patterns[data->npatterns].brightness,
&data->patterns[data->npatterns].delta_t, &cr);
- if (ccount != 2) {
+
+ if (ccount != 2 ||
+ data->patterns[data->npatterns].brightness > data->led_cdev->max_brightness) {
data->npatterns = 0;
return -EINVAL;
}