All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andi Kleen <ak@suse.de>
To: linux-kernel@vger.kernel.org
Cc: pj@sgi.com
Subject: [PATCH] Fix bitmap_scnlistprintf for empty masks
Date: Fri, 26 Oct 2007 03:42:42 +0200	[thread overview]
Message-ID: <200710260342.43058.ak@suse.de> (raw)


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>

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;

             reply	other threads:[~2007-10-26  1:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-26  1:42 Andi Kleen [this message]
2007-10-26  2:00 ` [PATCH] Fix bitmap_scnlistprintf for empty masks Paul Jackson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200710260342.43058.ak@suse.de \
    --to=ak@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pj@sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.