Skip to content

Commit

Permalink
Fix bitmap_scnlistprintf for empty masks
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Paul Jackson <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Andi Kleen authored and Linus Torvalds committed Nov 5, 2007
1 parent 5a75983 commit 0b030c2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0b030c2

Please sign in to comment.