summaryrefslogtreecommitdiff
path: root/drivers/leds/trigger
diff options
context:
space:
mode:
authorPavel Machek <pavel@ucw.cz>2020-07-24 13:43:47 +0300
committerPavel Machek <pavel@ucw.cz>2020-07-24 13:43:57 +0300
commitfeff72735b316e268da4ccc04091977e8f89a721 (patch)
treec4733e5dab0790595cdead18cfbea8a0f045a937 /drivers/leds/trigger
parentc5437338150e4914328c975767056d2dedacfd21 (diff)
downloadlinux-feff72735b316e268da4ccc04091977e8f89a721.tar.xz
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/trigger')
-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;
}