Re: p used before making sure it is not NULL in kernel/auditsc.c
From: Al Viro
Date: Fri May 22 2009 - 00:07:22 EST
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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/