Linux-LEDs Archive mirror
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: linux-leds@vger.kernel.org, kernel-janitors@vger.kernel.org,
	Pavel Machek <pavel@ucw.cz>, LKML <linux-kernel@vger.kernel.org>,
	cocci@inria.fr
Subject: Re: leds: trigger: oneshot: One function call less in pattern_init() after error detection
Date: Thu, 11 Jan 2024 13:05:13 +0000	[thread overview]
Message-ID: <20240111130513.GK1678981@google.com> (raw)
In-Reply-To: <58d6b9d0-a2d6-4d8d-bc36-fe783839ca79@web.de>

On Thu, 11 Jan 2024, Markus Elfring wrote:

> >> The kfree() function was called in one case by
> >> the pattern_init() function during error handling
> >> even if the passed variable contained a null pointer.
> >
> > It's totally valid to call kfree() on a NULL pointer:
> >
> >   * If @object is NULL, no operation is performed.
> >
> > Why do we care all that much?
> 
> Would you dare to categorise such special function calls as redundant?
> 
> Should they be skipped in more cases?
> 
> See also:
> https://wiki.sei.cmu.edu/confluence/display/c/MEM12-C.+Consider+using+a+goto+chain+when+leaving+a+function+on+error+when+using+and+releasing+resources

I have no idea what you're trying to say.

The premise of your patch is based on the fact that we shouldn't call
kfree() with a NULL pointer.  When in actual fact kfree() is more than
capable of handling cases where the passed object is NULL, and goes as
far as to document as such.  Meaning that unless I'm convinced
otherwise, patches like this remain in the category of churn.

-- 
Lee Jones [李琼斯]

      reply	other threads:[~2024-01-11 13:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-26 21:08 [PATCH] leds: trigger: oneshot: One function call less in pattern_init() after error detection Markus Elfring
2024-01-11 10:41 ` Lee Jones
2024-01-11 12:03   ` Markus Elfring
2024-01-11 13:05     ` Lee Jones [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=20240111130513.GK1678981@google.com \
    --to=lee@kernel.org \
    --cc=Markus.Elfring@web.de \
    --cc=cocci@inria.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@ucw.cz \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).