diff options
author | Andi Kleen <ak@suse.de> | 2007-11-05 17:50:56 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-11-05 18:12:32 -0500 |
commit | 0b030c2c2f0f1d98d5fe412e5b7cf7fd53f5221a (patch) | |
tree | ff10db5bc25c1aa3e7cc5c8dac6807d76fd7f506 /lib/bitmap.c | |
parent | 5a75983eef1193c43caebde6643a218bd8d8390e (diff) |
Fix bitmap_scnlistprintf for empty masks
When a bitmap is empty bitmap_scnlistprintf() would leave the buffer
uninitialized. Set it to an empty string in this case.
I didn't see any in normal kernel callers hitting this, but some custom
debug code of mine did.
Signed-off-by: Andi Kleen <ak@suse.de>
Acked-by: Paul Jackson <pj@sgi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/bitmap.c')
-rw-r--r-- | lib/bitmap.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/bitmap.c b/lib/bitmap.c index 26ebafa8c41..2c9242e3fed 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c | |||
@@ -469,6 +469,10 @@ int bitmap_scnlistprintf(char *buf, unsigned int buflen, | |||
469 | /* current bit is 'cur', most recently seen range is [rbot, rtop] */ | 469 | /* current bit is 'cur', most recently seen range is [rbot, rtop] */ |
470 | int cur, rbot, rtop; | 470 | int cur, rbot, rtop; |
471 | 471 | ||
472 | if (buflen == 0) | ||
473 | return 0; | ||
474 | buf[0] = 0; | ||
475 | |||
472 | rbot = cur = find_first_bit(maskp, nmaskbits); | 476 | rbot = cur = find_first_bit(maskp, nmaskbits); |
473 | while (cur < nmaskbits) { | 477 | while (cur < nmaskbits) { |
474 | rtop = cur; | 478 | rtop = cur; |