diff options
Diffstat (limited to 'lib/bitmap.c')
-rw-r--r-- | lib/bitmap.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/lib/bitmap.c b/lib/bitmap.c index 9a532805364b..c82c61b66e16 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c | |||
@@ -513,7 +513,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen, | |||
513 | int nmaskbits) | 513 | int nmaskbits) |
514 | { | 514 | { |
515 | unsigned int a, b, old_a, old_b; | 515 | unsigned int a, b, old_a, old_b; |
516 | unsigned int group_size, used_size; | 516 | unsigned int group_size, used_size, off; |
517 | int c, old_c, totaldigits, ndigits; | 517 | int c, old_c, totaldigits, ndigits; |
518 | const char __user __force *ubuf = (const char __user __force *)buf; | 518 | const char __user __force *ubuf = (const char __user __force *)buf; |
519 | int at_start, in_range, in_partial_range; | 519 | int at_start, in_range, in_partial_range; |
@@ -599,6 +599,8 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen, | |||
599 | a = old_a; | 599 | a = old_a; |
600 | b = old_b; | 600 | b = old_b; |
601 | old_a = old_b = 0; | 601 | old_a = old_b = 0; |
602 | } else { | ||
603 | used_size = group_size = b - a + 1; | ||
602 | } | 604 | } |
603 | /* if no digit is after '-', it's wrong*/ | 605 | /* if no digit is after '-', it's wrong*/ |
604 | if (at_start && in_range) | 606 | if (at_start && in_range) |
@@ -608,17 +610,9 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen, | |||
608 | if (b >= nmaskbits) | 610 | if (b >= nmaskbits) |
609 | return -ERANGE; | 611 | return -ERANGE; |
610 | while (a <= b) { | 612 | while (a <= b) { |
611 | if (in_partial_range) { | 613 | off = min(b - a + 1, used_size); |
612 | static int pos_in_group = 1; | 614 | bitmap_set(maskp, a, off); |
613 | 615 | a += group_size; | |
614 | if (pos_in_group <= used_size) | ||
615 | set_bit(a, maskp); | ||
616 | |||
617 | if (a == b || ++pos_in_group > group_size) | ||
618 | pos_in_group = 1; | ||
619 | } else | ||
620 | set_bit(a, maskp); | ||
621 | a++; | ||
622 | } | 616 | } |
623 | } while (buflen && c == ','); | 617 | } while (buflen && c == ','); |
624 | return 0; | 618 | return 0; |