From: Markus Elfring <Markus.Elfring@web.de>
To: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
netdev@vger.kernel.org, kernel-janitors@vger.kernel.org
Cc: Dan Carpenter <error27@gmail.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
MD Danish Anwar <danishanwar@ti.com>,
Michael Grzeschik <mgr@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
Vadim Fedorenko <vadim.fedorenko@linux.dev>,
Yibo Dong <dong100@mucse.com>,
LKML <linux-kernel@vger.kernel.org>,
Jonathan Corbet <corbet@lwn.net>
Subject: Re: net: rnpgbe: Pass an expression directly in rnpgbe_rm_adapter()
Date: Wed, 15 Jul 2026 20:45:48 +0200 [thread overview]
Message-ID: <85ad473e-b2f5-4458-8973-a643f90eda5e@web.de> (raw)
In-Reply-To: <aleFN4Z2XT3NP3od@monoceros>
Am 15.07.26 um 15:12 schrieb Uwe Kleine-König:
> On Mon, Jul 13, 2026 at 10:22:06AM +0200, Markus Elfring wrote:
>>>> The address of a data structure member was determined before
>>>> a corresponding null pointer check in the implementation of
>>>> the function “rnpgbe_rm_adapter”.
>>>>
>>>> Thus avoid the risk for undefined behaviour by omitting the variable “hw”.
>>>> Pass the required address directly to a function call.
>>>>
>>>> This issue was detected by using the Coccinelle software.
>>>>
>>>> Fixes: 2ee95ec17e97c58b65e978a08b75fa8cb6424e4e ("net: rnpgbe: Add register_netdev")
>>>
>>> There is no NULL dereference here. It's just pointer math.
>>> No need for a Fixes tag.
>>
>> How does your view fit to information in an article like “Fun with
>> NULL pointers, part 1”(by Jonathan Corbet from 2009-07-20)?
>> https://lwn.net/Articles/342330/
>
> It does fit, because the problematic code discussed in Jonathan Corbet's
> article is of the type:
>
> int i = ptr->i;
>
> if (!ptr)
> do_something();
>
> while here we have:
>
> int *i = &ptr->i;
>
> if (!ptr)
> do_something();
>
> which at least in my test[1] is relevantly different.
Jonathan Corbet provided the following information.
“…
But Herbert's patch added a line which dereferences the pointer prior to the check. That, of course, is a bug.
…”
> Note, I didn't
> study the C standard
I hope that clarification approaches can evolve further according to this information source.
> if the compiler is free to optimize out
> do_something() also in the 2nd case, but at least today gcc doesn't.
Can development interests grow also according to another clarification approach?
Does &((struct name *)NULL -> b) cause undefined behaviour in C11?
https://stackoverflow.com/questions/26906621/does-struct-name-null-b-cause-undefined-behaviour-in-c11
Would you prefer to omit a “sanity check” in the discussed function implementation?
Regards,
Markus
next prev parent reply other threads:[~2026-07-15 18:46 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-12 18:35 [PATCH net] net: rnpgbe: Pass an expression directly in rnpgbe_rm_adapter() Markus Elfring
2026-07-12 22:19 ` Vadim Fedorenko
2026-07-13 6:00 ` Markus Elfring
2026-07-13 8:04 ` [PATCH net] " Dan Carpenter
2026-07-13 8:22 ` Markus Elfring
2026-07-15 13:12 ` Uwe Kleine-König
2026-07-15 18:45 ` Markus Elfring [this message]
2026-07-16 9:30 ` Dan Carpenter
2026-07-16 9:48 ` Markus Elfring
2026-07-16 13:24 ` Andrew Lunn
2026-07-16 13:34 ` Dan Carpenter
2026-07-16 13:43 ` Andrew Lunn
2026-07-16 17:26 ` [PATCH v2 net-next] net: rnpgbe: Delete a null pointer check " Markus Elfring
2026-07-16 6:57 ` [PATCH net] net: rnpgbe: Pass an expression directly " Dan Carpenter
2026-07-16 8:20 ` Markus Elfring
2026-07-16 13:30 ` Dan Carpenter
2026-07-16 16:19 ` Markus Elfring
2026-07-16 14:27 ` Jonathan Corbet
2026-07-16 16:30 ` Markus Elfring
2026-07-14 22:20 ` [PATCH net] " Andrew Lunn
2026-07-15 5:22 ` Markus Elfring
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=85ad473e-b2f5-4458-8973-a643f90eda5e@web.de \
--to=markus.elfring@web.de \
--cc=andrew+netdev@lunn.ch \
--cc=corbet@lwn.net \
--cc=danishanwar@ti.com \
--cc=davem@davemloft.net \
--cc=dong100@mucse.com \
--cc=edumazet@google.com \
--cc=error27@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mgr@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=u.kleine-koenig@baylibre.com \
--cc=vadim.fedorenko@linux.dev \
/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