From: "Vegard Nossum" <vegard.nossum@gmail.com>
To: "Jim Houston" <jim.houston@ccur.com>
Cc: "Ingo Molnar" <mingo@elte.hu>, "Tejun Heo" <htejun@gmail.com>,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>
Subject: lib/idr.c: initialize struct idr_layer
Date: Sun, 27 Jan 2008 21:07:01 +0100 [thread overview]
Message-ID: <19f34abd0801271207j377fba5bg92cedceedbdd228@mail.gmail.com> (raw)
Hi,
I am testing my kmemcheck patches, and it has come up with a couple of
uses of uninitialized memory in lib/idr.c. These are (the line numbers
may differ slightly):
line 135 (sub_alloc): bm = ~p->bitmap;
p->bitmap is uninitialized
line 171 (sub_alloc): if (!p->ary[m]) {
p->ary is uninitialized
line 249 (idr_get_new_above_int): pa[0]->count++;
pa[0]->count is uninitialized
I cannot guarantee that these are truly errors, but I would be
grateful if you could help me confirm/deny the validity of the
reports. Personally, I can get rid of the errors using this patch:
diff --git a/lib/idr.c b/lib/idr.c
index afbb0b1..dd28ee5 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -39,12 +39,16 @@ static struct idr_layer *alloc_layer(struct idr *idp)
{
struct idr_layer *p;
unsigned long flags;
+ int i;
spin_lock_irqsave(&idp->lock, flags);
if ((p = idp->id_free)) {
idp->id_free = p->ary[0];
idp->id_free_cnt--;
- p->ary[0] = NULL;
+ p->bitmap = 0;
+ for(i = 0; i < ARRAY_SIZE(p->ary); ++i)
+ p->ary[i] = NULL;
+ p->count = 0;
}
spin_unlock_irqrestore(&idp->lock, flags);
return(p);
Thanks a lot.
Vegard
next reply other threads:[~2008-01-27 20:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-27 20:07 Vegard Nossum [this message]
2008-01-27 21:00 ` Pekka Enberg
2008-01-27 21:17 ` Vegard Nossum
2008-01-27 21:21 ` Pekka J Enberg
2008-01-27 21:30 ` Vegard Nossum
2008-01-27 21:35 ` Pekka Enberg
2008-01-27 21:56 ` Vegard Nossum
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=19f34abd0801271207j377fba5bg92cedceedbdd228@mail.gmail.com \
--to=vegard.nossum@gmail.com \
--cc=htejun@gmail.com \
--cc=jim.houston@ccur.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®