mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* lib/idr.c: initialize struct idr_layer
@ 2008-01-27 20:07 Vegard Nossum
  2008-01-27 21:00 ` Pekka Enberg
  0 siblings, 1 reply; 7+ messages in thread
From: Vegard Nossum @ 2008-01-27 20:07 UTC (permalink / raw)
  To: Jim Houston; +Cc: Ingo Molnar, Tejun Heo, Linux Kernel Mailing List

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-01-27 21:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-27 20:07 lib/idr.c: initialize struct idr_layer Vegard Nossum
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

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®