Skip to contentSkip to conversation

Fix bitmap_scnlistprintf for empty masks

PATCH In review Andi Kleen 2 participants 2 messages Oct 26, 2007

Subsystems (2)
lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/1 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.

lib/bitmap.c +4 -0
Index: linux-2.6.24-rc1-hack/lib/bitmap.c
===================================================================
@@ -469,6 +469,10 @@ int bitmap_scnlistprintf(char *buf, unsi
 	/* 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;
Acked-by on v1 1/1
#1 lore raw
Quoted 2 lines · Andi

When a bitmap is empty bitmap_scnlistprintf would leave the buffer uninitialized. Set it to an empty string in this case.

Signature · 3 lines
                  I won't rest till it's the best ...
                  Programmer, Linux Scalability
                  Paul Jackson <[email protected]> 1.925.600.0401