Home Home > GIT Browse > stable-xen
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2019-08-01 07:59:19 +0200
committerTakashi Iwai <tiwai@suse.de>2019-08-01 10:42:52 +0200
commit31d0aacc63f418fa60d277c707a895b6bfbc62b8 (patch)
treebe2acb458bcc5ec64acc87ab7e736ff330d69821
parentffeccb2fbae0eca281e3df9359b6301dbe5dcdcd (diff)
lib/bitmap.c: make bitmap_parselist() thread-safe and muchrpm-4.12.14-150.32--sle15-updatesrpm-4.12.14-150.32
faster (bsc#1143507). suse-commit: a2a3983fef2c0a89c8f93a28f7a09a90697dd25a
-rw-r--r--lib/bitmap.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 9a8d4ecdbc52..2a9373ef4054 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -513,7 +513,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
int nmaskbits)
{
unsigned int a, b, old_a, old_b;
- unsigned int group_size, used_size;
+ unsigned int group_size, used_size, off;
int c, old_c, totaldigits, ndigits;
const char __user __force *ubuf = (const char __user __force *)buf;
int at_start, in_range, in_partial_range;
@@ -599,6 +599,8 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
a = old_a;
b = old_b;
old_a = old_b = 0;
+ } else {
+ used_size = group_size = b - a + 1;
}
/* if no digit is after '-', it's wrong*/
if (at_start && in_range)
@@ -608,17 +610,9 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
if (b >= nmaskbits)
return -ERANGE;
while (a <= b) {
- if (in_partial_range) {
- static int pos_in_group = 1;
-
- if (pos_in_group <= used_size)
- set_bit(a, maskp);
-
- if (a == b || ++pos_in_group > group_size)
- pos_in_group = 1;
- } else
- set_bit(a, maskp);
- a++;
+ off = min(b - a + 1, used_size);
+ bitmap_set(maskp, a, off);
+ a += group_size;
}
} while (buflen && c == ',');
return 0;