diff options
author | Pavel Machek <pavel@ucw.cz> | 2020-07-24 12:43:47 +0200 |
---|---|---|
committer | Pavel Machek <pavel@ucw.cz> | 2020-07-24 12:43:57 +0200 |
commit | feff72735b316e268da4ccc04091977e8f89a721 (patch) | |
tree | c4733e5dab0790595cdead18cfbea8a0f045a937 | |
parent | c5437338150e4914328c975767056d2dedacfd21 (diff) |
leds: pattern trigger -- check pattern for validity
Don't allow invalid brightness in the pattern.
Signed-off-by: Pavel Machek <pavel@ucw.cz>
-rw-r--r-- | drivers/leds/trigger/ledtrig-pattern.c | 6 |
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; } |