[PATCH] Fix bitmap_scnlistprintf for empty masks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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]>

Index: linux-2.6.24-rc1-hack/lib/bitmap.c
===================================================================
--- linux-2.6.24-rc1-hack.orig/lib/bitmap.c
+++ 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;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux