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

>> 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


Regards,
Markus

      parent reply	other threads:[~2024-01-11 12:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-26 21:08 [cocci] [PATCH] leds: trigger: oneshot: One function call less in pattern_init() after error detection Markus Elfring
     [not found] ` <20240111104109.GB1665043@google.com>
2024-01-11 12:03   ` Markus Elfring [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=58d6b9d0-a2d6-4d8d-bc36-fe783839ca79@web.de \
    --to=markus.elfring@web.de \
    --cc=cocci@inria.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=lee@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).