mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 12:28:41 +08:00
leds: pattern trigger -- check pattern for validity
Don't allow invalid brightness in the pattern. Signed-off-by: Pavel Machek <pavel@ucw.cz>
This commit is contained in:
parent
c543733815
commit
feff72735b
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user