From: David Miller <davem@davemloft.net>
To: dan.carpenter@oracle.com
Cc: paul@paul-moore.com, netdev@vger.kernel.org,
kuznet@ms2.inr.ac.ru, jmorris@namei.org, yoshfuji@linux-ipv6.org,
kaber@trash.net, kernel-janitors@vger.kernel.org
Subject: Re: [patch] cipso: remove an unneeded NULL check in cipso_v4_doi_add()
Date: Tue, 11 Oct 2011 18:42:52 -0400 (EDT) [thread overview]
Message-ID: <20111011.184252.617974451481415643.davem@davemloft.net> (raw)
In-Reply-To: <20111011215549.GC30887@longonot.mountain>
From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Wed, 12 Oct 2011 00:55:49 +0300
> On Tue, Oct 11, 2011 at 05:20:11PM -0400, Paul Moore wrote:
>> > - if (doi_def == NULL || doi_def->doi == CIPSO_V4_DOI_UNKNOWN)
>> > + if (doi_def->doi == CIPSO_V4_DOI_UNKNOWN)
>> > goto doi_add_return;
>> > for (iter = 0; iter < CIPSO_V4_TAG_MAXCNT; iter++) {
>> > switch (doi_def->tags[iter]) {
>>
>> I'd prefer to keep the NULL check in there as it does afford a little
>> bit of extra safety and this is management code after all, not
>> per-packet processing code, so the extra check should have no
>> observable performance impact.
>
> The dereferences on the lines before mean we would Oops before
> reaching the check. But I guess I can move the check forward. The
> error handling at goto doi_add_return relies on a non-NULL value for
> doi_def but I could just put a return in front of the dereference.
>
> if (!doi_def)
> return -EINVAL;
>
> I'll send a patch to do this tomorrow.
I think your original patch is still the best one.
Saying the NULL check should stay to provide "extra safety" is
complete garbage. Especially since, as Dan shows, we dereference the
pointer before to damn check.
I'll therefore apply Dan's original patch.
next prev parent reply other threads:[~2011-10-11 22:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-11 13:22 [patch] cipso: remove an unneeded NULL check in cipso_v4_doi_add() Dan Carpenter
2011-10-11 21:20 ` Paul Moore
2011-10-11 21:55 ` Dan Carpenter
2011-10-11 22:42 ` David Miller [this message]
2011-10-12 21:28 ` Paul Moore
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=20111011.184252.617974451481415643.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=dan.carpenter@oracle.com \
--cc=jmorris@namei.org \
--cc=kaber@trash.net \
--cc=kernel-janitors@vger.kernel.org \
--cc=kuznet@ms2.inr.ac.ru \
--cc=netdev@vger.kernel.org \
--cc=paul@paul-moore.com \
--cc=yoshfuji@linux-ipv6.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;
as well as URLs for NNTP newsgroup(s).