[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20111011.184252.617974451481415643.davem@davemloft.net>
Date: Tue, 11 Oct 2011 18:42:52 -0400 (EDT)
From: David Miller <davem@...emloft.net>
To: dan.carpenter@...cle.com
Cc: paul@...l-moore.com, netdev@...r.kernel.org, kuznet@....inr.ac.ru,
jmorris@...ei.org, yoshfuji@...ux-ipv6.org, kaber@...sh.net,
kernel-janitors@...r.kernel.org
Subject: Re: [patch] cipso: remove an unneeded NULL check in
cipso_v4_doi_add()
From: Dan Carpenter <dan.carpenter@...cle.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.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists