From: Al Viro <viro@ZenIV.linux.org.uk>
To: Zhenwen Xu <helight.xu@gmail.com>
Cc: linux-kernel@vger.kernel.org, eparis@redhat.com
Subject: Re: p used before making sure it is not NULL in kernel/auditsc.c
Date: Fri, 22 May 2009 05:07:04 +0100 [thread overview]
Message-ID: <20090522040704.GW8633@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20090522022241.GA3350@helight>
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.
prev parent reply other threads:[~2009-05-22 4:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-22 2:22 p used before making sure it is not NULL in kernel/auditsc.c Zhenwen Xu
2009-05-22 4:07 ` Al Viro [this message]
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=20090522040704.GW8633@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=eparis@redhat.com \
--cc=helight.xu@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/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