mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
To: Przemek Kitszel <przemyslaw.kitszel@intel.com>,
	Tony Nguyen <anthony.l.nguyen@intel.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org,
	Ally Heev <allyheev@gmail.com>,
	linux-kernel@vger.kernel.org, Simon Horman <horms@kernel.org>,
	Dan Carpenter <dan.carpenter@linaro.org>
Subject: Re: __free usage
Date: Fri, 7 Aug 2026 07:11:33 -0700	[thread overview]
Message-ID: <2480a569-de5f-4d91-9b9f-60a46613e5ef@oss.qualcomm.com> (raw)
In-Reply-To: <8f35edd6-6b37-4575-8a30-558ae0dee0bd@intel.com>

On 8/5/2026 4:56 AM, Przemek Kitszel wrote:
> On 8/5/26 00:56, Jeff Johnson via Intel-wired-lan wrote:
>> On 8/4/2026 3:54 PM, Jeff Johnson wrote:
>>> On 11/16/2025 7:56 AM, Ally Heev wrote:
>>>> usage of cleanup attributes is discouraged in net [1], achieve cleanup
>>>> using goto. In this patch though, only uninitialized pointers with __free
>>>> attribute are cleaned as they can cause undefined behavior when they
>>>> go out of scope
>>>>
>>>> Suggested-by: Simon Horman <horms@kernel.org>
>>>> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
>>>> Closes: https://lore.kernel.org/all/aPiG_F5EBQUjZqsl@stanley.mountain/
>>>> Signed-off-by: Ally Heev <allyheev@gmail.com>
>>>>
>>>> [1] https://docs.kernel.org/process/maintainer-netdev.html#using-device-managed-and-cleanup-h-constructs
>>>
>>> <SMH>
>>>
>>> If using __free() *correctly* gives more readable code, why wouldn't we do it?
>>>
>>> The only problem with this function is that it doesn't follow the guidance
>>> from cleanup.h:
>>>
>>>   * the recommendation is to always define and assign variables in one
>>>   * statement and not group variable definitions at the top of the
>>>   * function when __free() is used.
>> OMG, not sure why Thunderbird showed this as a recent unread e-mail.
>> Please ignore this noise!
> 
> always happy to see some __free() advocates :)
> 
> perhaps with our new meticulous friend Sashiko __free() would not be
> misused anymore, especially if we let them know the following quote:
> 
>  > So just make the rule be that __free() without an assignment is 
> simply > a bug.
>  >               Linus
> 
> and the resulting "less code" is always better (if only to fit more
> data into the AI context window)

There are unfortunately some uses of __free() that require a NULL assignment,
namely when the allocation is passed back via  a ** argument -- see
__free(firmware). But for all the rest it would be good to have the
consistency. Anything to help reduce often buggy cleanup gotos.

/jeff

      reply	other threads:[~2026-08-07 14:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-16 15:56 [PATCH RFT net-next 0/2] ethernet: intel: fix freeing uninitialized pointers with __free Ally Heev
2025-11-16 15:56 ` [PATCH RFT net-next 1/2] ice: remove __free usage in ice_flow Ally Heev
2025-11-16 15:56 ` [PATCH RFT net-next 2/2] idpf: remove __free usage in idpf_virtchnl Ally Heev
2026-08-04 22:54   ` Jeff Johnson
2026-08-04 22:56     ` Jeff Johnson
2026-08-05 11:56       ` __free usage Przemek Kitszel
2026-08-07 14:11         ` Jeff Johnson [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=2480a569-de5f-4d91-9b9f-60a46613e5ef@oss.qualcomm.com \
    --to=jeff.johnson@oss.qualcomm.com \
    --cc=allyheev@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=anthony.l.nguyen@intel.com \
    --cc=dan.carpenter@linaro.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    /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®