diff options
| author | Pan Xinhui <[email protected]> | 2015-09-09 22:37:05 +0000 |
|---|---|---|
| committer | Linus Torvalds <[email protected]> | 2015-09-10 20:29:01 +0000 |
| commit | d9282cb66353be502aae09aae75d05a6863eb979 (patch) | |
| tree | 78ae23870c4f19225303b2d820cebd87aa1153ed /lib/bitmap.c | |
| parent | lib/bitmap.c: correct a code style and do some, optimization (diff) | |
| download | kernel-d9282cb66353be502aae09aae75d05a6863eb979.tar.gz kernel-d9282cb66353be502aae09aae75d05a6863eb979.zip | |
lib/bitmap.c: fix a special string handling bug in __bitmap_parselist
If string end with '-', for exapmle, bitmap_parselist("1,0-",&mask,
nmaskbits), It is not in a valid pattern, so add a check after loop.
Return -EINVAL on such condition.
Signed-off-by: Pan Xinhui <[email protected]>
Cc: Yury Norov <[email protected]>
Cc: Chris Metcalf <[email protected]>
Cc: Rasmus Villemoes <[email protected]>
Cc: Sudeep Holla <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Diffstat (limited to 'lib/bitmap.c')
| -rw-r--r-- | lib/bitmap.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/bitmap.c b/lib/bitmap.c index eb21456be4b9..f549176e9250 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c @@ -546,6 +546,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen, return -EINVAL; b = 0; in_range = 1; + at_start = 1; continue; } @@ -558,6 +559,9 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen, at_start = 0; totaldigits++; } + /* if no digit is after '-', it's wrong*/ + if (at_start && in_range) + return -EINVAL; if (!(a <= b)) return -EINVAL; if (b >= nmaskbits) |
