From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Markus Elfring <Markus.Elfring@web.de>,
Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
netdev@vger.kernel.org, kernel-janitors@vger.kernel.org,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
Stephen Hemminger <stephen@networkplumber.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: packet: Improve exception handling in fanout_add()
Date: Mon, 01 Jan 2024 10:29:21 -0500 [thread overview]
Message-ID: <6592da5178589_238b0d2943a@willemb.c.googlers.com.notmuch> (raw)
In-Reply-To: <a69fce11-68c2-446c-9da8-b959bb3ba70f@web.de>
Markus Elfring wrote:
> > It is fine to call kfree with a possible NULL pointer:
> …
> > * If @object is NULL, no operation is performed.
> > */
> > void kfree(const void *object)
>
> Such a function call triggers an input parameter validation
> with a corresponding immediate return, doesn't it?
> Do you find such data processing really helpful for the desired error/exception handling?
It's not just personal preference. It is an established pattern to
avoid extra NULL tests around kfree.
A quick git log to show a few recent examples of patches that expressly
remove such branches, e.g.,
commit d0110443cf4a ("amd/pds_core: core: No need for Null pointer check before kfree")
commit efd9d065de67 ("drm/radeon: Remove unnecessary NULL test before kfree in 'radeon_connector_free_edid'")
An interesting older thread on the topic:
https://linux-kernel.vger.kernel.narkive.com/KVjlDsTo/kfree-null
My summary, the many branches scattered throughout the kernel likely
are more expensive than the occasional save from seeing the rare NULL
pointer.
next prev parent reply other threads:[~2024-01-01 15:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-31 15:39 [PATCH] " Markus Elfring
2023-12-31 21:45 ` Willem de Bruijn
2024-01-01 9:46 ` Markus Elfring
2024-01-01 15:29 ` Willem de Bruijn [this message]
2024-01-01 16:33 ` David Laight
2024-01-01 18:12 ` Stephen Hemminger
2024-01-02 7:32 ` Markus Elfring
2023-12-31 22:44 ` [PATCH] " Stephen Hemminger
2024-01-02 16:30 ` Stephen Hemminger
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=6592da5178589_238b0d2943a@willemb.c.googlers.com.notmuch \
--to=willemdebruijn.kernel@gmail.com \
--cc=Markus.Elfring@web.de \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stephen@networkplumber.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
all inboxes | Powered by JetHome®