[PATCH] lib/bitmap.c: add some check to correct the parse result
From: Pan Xinhui
Date: Fri Jun 26 2015 - 02:38:49 EST
Sometimes the input from user may cause an unexpected result.
for example, echo "1-3," > /proc/irq/<xxx>/smp_affinity_list.
The correct result should be 1-3, however we got 0-4.
To avoid this issue, we check if there is a ready digit.
If no valid digit is set, we just continue to the next parse.
Signed-off-by: Pan Xinhui <xinhuix.pan@xxxxxxxxx>
---
lib/bitmap.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 64c0926..3c489c1 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -561,6 +561,8 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
return -EINVAL;
if (b >= nmaskbits)
return -ERANGE;
+ if (unlikely(exp_digit))
+ continue;
while (a <= b) {
set_bit(a, maskp);
a++;
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/