[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20090522040704.GW8633@ZenIV.linux.org.uk>
Date: Fri, 22 May 2009 05:07:04 +0100
From: Al Viro <viro@...IV.linux.org.uk>
To: Zhenwen Xu <helight.xu@...il.com>
Cc: linux-kernel@...r.kernel.org, eparis@...hat.com
Subject: Re: p used before making sure it is not NULL in kernel/auditsc.c
On Fri, May 22, 2009 at 10:22:41AM +0800, Zhenwen Xu wrote:
> p used before making sure it is not NULL in kernel/auditsc.c
>
> here we should make sure the p is not NULL then use it.
NAK. ->tree_count can become non-zero only after we had set ->trees
non-NULL. It's "how much free slots is left in current->trees".
If it's zero, we might have an empty chain (->trees is NULL, we bugger
off and caller tries to allocate) *or* we might be at the end of the
chain (->trees->next is NULL, same as previous) *or* we have more
allocated blocks in the chain, so we move to the next block and
store in there.
As a general note,
if (foo) {
...
dereference p;
...
} else if (p) {
...
dereference p;
...
}
is a perfectly sane code, if foo is true only when p != NULL.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists