dect
/
linux-2.6
Archived
13
0
Fork 0

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>
This commit is contained in:
Andi Kleen 2007-11-05 14:50:56 -08:00 committed by Linus Torvalds
parent 5a75983eef
commit 0b030c2c2f
1 changed files with 4 additions and 0 deletions

View File

@ -469,6 +469,10 @@ int bitmap_scnlistprintf(char *buf, unsigned int buflen,
/* current bit is 'cur', most recently seen range is [rbot, rtop] */
int cur, rbot, rtop;
if (buflen == 0)
return 0;
buf[0] = 0;
rbot = cur = find_first_bit(maskp, nmaskbits);
while (cur < nmaskbits) {
rtop = cur;