aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPan Xinhui <xinhuix.pan@intel.com>2015-09-09 18:37:05 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-09-10 16:29:01 -0400
commitd9282cb66353be502aae09aae75d05a6863eb979 (patch)
tree78ae23870c4f19225303b2d820cebd87aa1153ed /lib
parentd21c3d4d1c6b2a0b85aeae5cc774b1bacc64e5b4 (diff)
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 <xinhuix.pan@intel.com> Cc: Yury Norov <yury.norov@gmail.com> Cc: Chris Metcalf <cmetcalf@ezchip.com> Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk> Cc: Sudeep Holla <sudeep.holla@arm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/bitmap.c4
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,
546 return -EINVAL; 546 return -EINVAL;
547 b = 0; 547 b = 0;
548 in_range = 1; 548 in_range = 1;
549 at_start = 1;
549 continue; 550 continue;
550 } 551 }
551 552
@@ -558,6 +559,9 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
558 at_start = 0; 559 at_start = 0;
559 totaldigits++; 560 totaldigits++;
560 } 561 }
562 /* if no digit is after '-', it's wrong*/
563 if (at_start && in_range)
564 return -EINVAL;
561 if (!(a <= b)) 565 if (!(a <= b))
562 return -EINVAL; 566 return -EINVAL;
563 if (b >= nmaskbits) 567 if (b >= nmaskbits)