public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: alexious@zju.edu.cn
To: "Jakub Kicinski" <kuba@kernel.org>
Cc: "Chris Snook" <chris.snook@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Simon Horman" <horms@kernel.org>,
	"Yuanjun Gong" <ruc_gongyuanjun@163.com>,
	"Jie Yang" <jie.yang@atheros.com>,
	"Jeff Garzik" <jgarzik@redhat.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: Re: [PATCH] [v2] ethernet: atheros: fix a memleak in atl1e_setup_ring_resources
Date: Thu, 14 Dec 2023 21:05:27 +0800 (GMT+08:00)	[thread overview]
Message-ID: <632c5358.35eae.18c686e98f2.Coremail.alexious@zju.edu.cn> (raw)
In-Reply-To: <20231211191447.0408689d@kernel.org>


> On Fri,  8 Dec 2023 16:23:14 +0800 Zhipeng Lu wrote:
> > v2: Setting tx_ring->tx_buffer to NULL after free.
> 
> Having closer look at this driver  - it tries to free both on close and
> remove, so seems like we do indeed have to NULL-out the pointer, sigh.
> 
> > diff --git a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
> > index 5935be190b9e..1bffe77439ac 100644
> > --- a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
> > +++ b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
> > @@ -866,6 +866,8 @@ static int atl1e_setup_ring_resources(struct atl1e_adapter *adapter)
> >  		netdev_err(adapter->netdev, "offset(%d) > ring size(%d) !!\n",
> >  			   offset, adapter->ring_size);
> >  		err = -1;
> > +		kfree(tx_ring->tx_buffer);
> > +		tx_ring->tx_buffer = NULL;
> >  		goto failed;
> 
> Please add a new jump target, tho, and move the freeing there.
> There's a small chance someone will add more code to this function
> and it will need to copy / paste this unwind.
> -- 

Thank you for your advice, I've send a v3 version of this patch.

      reply	other threads:[~2023-12-14 13:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-08  8:23 [PATCH] [v2] ethernet: atheros: fix a memleak in atl1e_setup_ring_resources Zhipeng Lu
2023-12-08  8:51 ` [EXT] " Suman Ghosh
2023-12-12  3:14 ` Jakub Kicinski
2023-12-14 13:05   ` alexious [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=632c5358.35eae.18c686e98f2.Coremail.alexious@zju.edu.cn \
    --to=alexious@zju.edu.cn \
    --cc=chris.snook@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jgarzik@redhat.com \
    --cc=jie.yang@atheros.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=ruc_gongyuanjun@163.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