public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib/bitmap.c: add some check to correct the parse result
@ 2015-06-27  6:36 Pan Xinhui
  2015-07-09 22:57 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Pan Xinhui @ 2015-06-27  6:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, linux, tj, mnipxh

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@intel.com>
---
  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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-07-10  6:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-27  6:36 [PATCH] lib/bitmap.c: add some check to correct the parse result Pan Xinhui
2015-07-09 22:57 ` Andrew Morton
2015-07-10  6:03   ` Pan Xinhui

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox