intel-wired-lan.osuosl.org archive mirror
 help / color / mirror / Atom feed
From: ally heev <allyheev@gmail.com>
To: Przemek Kitszel <przemyslaw.kitszel@intel.com>,
	Tony Nguyen	 <anthony.l.nguyen@intel.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org,
	 linux-kernel@vger.kernel.org,
	Dan Carpenter <dan.carpenter@linaro.org>,
	 Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet	 <edumazet@google.com>,
	Alexander Lobakin <aleksander.lobakin@intel.com>,
	 Simon Horman <horms@kernel.org>
Subject: Re: [Intel-wired-lan] [RFT net-next PATCH RESEND 0/2] ethernet: intel: fix freeing uninitialized pointers with __free
Date: Mon, 08 Dec 2025 08:37:24 +0530	[thread overview]
Message-ID: <a137d0a4f3479b6164307a49b9193746db95fba9.camel@gmail.com> (raw)
In-Reply-To: <df193ddb-4591-417d-8d62-42d99d6d468f@intel.com>

On Wed, 2025-12-03 at 09:45 +0100, Przemek Kitszel wrote:
> On 12/3/25 09:09, ally heev wrote:
> > On Tue, 2025-12-02 at 10:17 -0800, Tony Nguyen wrote:
> > > 
> > > On 12/2/2025 11:47 AM, ally heev wrote:
> > > > On Mon, 2025-12-01 at 13:40 -0800, Tony Nguyen wrote:
> > > > > 
> > > > > On 11/23/2025 11:40 PM, Ally Heev wrote:
> > > > > > Uninitialized pointers with `__free` attribute can cause undefined
> > > > > > behavior as the memory assigned randomly to the pointer is freed
> > > > > > automatically when the pointer goes out of scope.
> > > > > > 
> > > > > > We could just fix it by initializing the pointer to NULL, but, as usage of
> > > > > > cleanup attributes is discouraged in net [1], trying to achieve cleanup
> > > > > > using goto
> > > > > 
> > > > > These two drivers already have multiple other usages of this. All the
> > > > > other instances initialize to NULL; I'd prefer to see this do the same
> > > > > over changing this single instance.
> > > > > 
> > > > 
> > > > Other usages are slightly complicated to be refactored and might need
> > > > good testing. Do you want me to do it in a different series?
> > > 
> > > Hi Ally,
> > > 
> > > Sorry, I think I was unclear. I'd prefer these two initialized to NULL,
> > > to match the other usages, over removing the __free() from them.
> > 
> > I had a patch for that already, but, isn't using __free discouraged in
> > networking drivers [1]? Simon was against it [2]
> 
> you see, the construct is discouraged, so we don't use it everywhere,
> but cleaning up just a little would not change the state of the matter
> (IOW we will still be in "driver has some __free() usage" state).
> 

But still we can just fix the uninitialized ones the right way [1]
right? since we have to fix them anyway. There already a patch [2] for
that

[1]
https://lore.kernel.org/lkml/CAHk-=wiCOTW5UftUrAnvJkr6769D29tF7Of79gUjdQHS_TkF5A@mail.gmail.com/
[2]
https://lore.kernel.org/all/20251106-aheev-uninitialized-free-attr-net-ethernet-v3-1-ef2220f4f476@gmail.com/

> TBH, I would not spent my time "undoing" all of the __free() that we
> have already, especially the testing part sounds not fun.

+1

> 
> Turning all usage points to "= NULL" is orthogonal, and would be great.
> 
> > 
> > [2] https://lore.kernel.org/all/aQ9xp9pchMwml30P@horms.kernel.org/
> > [1] https://docs.kernel.org/process/maintainer-netdev.html#using-device-managed-and-cleanup-h-constructs
> > 
> > Regards,
> > Ally
> > 

      reply	other threads:[~2025-12-08  3:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-24  7:40 [Intel-wired-lan] [RFT net-next PATCH RESEND 0/2] ethernet: intel: fix freeing uninitialized pointers with __free Ally Heev
2025-11-24  7:40 ` [Intel-wired-lan] [PATCH RESEND RFT net-next 1/2] ice: remove __free usage in ice_flow Ally Heev
2025-11-24 10:00   ` Loktionov, Aleksandr
2025-11-24  7:40 ` [Intel-wired-lan] [PATCH RESEND RFT net-next 2/2] idpf: remove __free usage in idpf_virtchnl Ally Heev
2025-11-24  9:59   ` Loktionov, Aleksandr
2025-12-01 21:40 ` [Intel-wired-lan] [RFT net-next PATCH RESEND 0/2] ethernet: intel: fix freeing uninitialized pointers with __free Tony Nguyen
2025-12-02 19:47   ` ally heev
2025-12-02 18:17     ` Tony Nguyen
2025-12-03  8:09       ` ally heev
2025-12-03  8:45         ` Przemek Kitszel
2025-12-08  3:07           ` ally heev [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=a137d0a4f3479b6164307a49b9193746db95fba9.camel@gmail.com \
    --to=allyheev@gmail.com \
    --cc=aleksander.lobakin@intel.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;
as well as URLs for NNTP newsgroup(s).