]> Git Repo - linux.git/commitdiff
Fix bitmap_scnlistprintf for empty masks
authorAndi Kleen <[email protected]>
Mon, 5 Nov 2007 22:50:56 +0000 (14:50 -0800)
committerLinus Torvalds <[email protected]>
Mon, 5 Nov 2007 23:12:32 +0000 (15:12 -0800)
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]>
lib/bitmap.c

index 26ebafa8c41d7e0ff602c0d2137a8ea284bb1ae5..2c9242e3fed01ca348b4171db2c0d89333fa357e 100644 (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;
This page took 0.054215 seconds and 4 git commands to generate.