diff options
| author | James Morris <james.l.morris@oracle.com> | 2017-09-24 22:41:55 -0700 | 
|---|---|---|
| committer | James Morris <james.l.morris@oracle.com> | 2017-09-24 22:41:55 -0700 | 
| commit | 25eabb13c7d67ae32298015c5e28d00f604f412c (patch) | |
| tree | 5bd75c2c1e385c79425bb099f0d19db7fb9c391f /lib/bitmap.c | |
| parent | ab5348c9c23cd253f5902980d2d8fe067dc24c82 (diff) | |
| parent | e19b205be43d11bff638cad4487008c48d21c103 (diff) | |
Merge tag 'v4.14-rc2' into next-general
Linux 4.14-rc2
Sync to v4.14-rc2 for security subsystem developers to track.
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,  		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;  | 
