Netdev List
 help / color / mirror / Atom feed
From: Joe Damato <joe@dama.to>
To: Chenguang Zhao <chenguang.zhao@linux.dev>
Cc: cai.huoqing@linux.dev, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, netdev@vger.kernel.org,
	Chenguang Zhao <zhaochenguang@kylinos.cn>
Subject: Re: [PATCH net] hinic: fix leak of ethtool RSS user configuration buffers
Date: Mon, 20 Jul 2026 06:01:21 -0700	[thread overview]
Message-ID: <al4cIYk8hEulreoI@devvm20253.cco0.facebook.com> (raw)
In-Reply-To: <20260720091102.1653378-1-chenguang.zhao@linux.dev>

On Mon, Jul 20, 2026 at 05:11:02PM +0800, Chenguang Zhao wrote:
> From: Chenguang Zhao <zhaochenguang@kylinos.cn>
> 
> rss_indir_user and rss_hkey_user are allocated in __set_rss_rxfh() when
> the user configures RSS via ethtool, but hinic_remove() never frees them.
> free_netdev() only releases the nic_dev structure itself, so the separately
> allocated buffers are leaked on driver unload.
> 
> Free both buffers in hinic_remove() after unregister_netdev().
> 
> Fixes: 4fdc51bb4e92 ("hinic: add support for rss parameters with ethtool")
> Signed-off-by: Chenguang Zhao <zhaochenguang@kylinos.cn>
> ---
>  drivers/net/ethernet/huawei/hinic/hinic_main.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/ethernet/huawei/hinic/hinic_main.c b/drivers/net/ethernet/huawei/hinic/hinic_main.c
> index 42f4792d255b..7d9c46004bcd 100644
> --- a/drivers/net/ethernet/huawei/hinic/hinic_main.c
> +++ b/drivers/net/ethernet/huawei/hinic/hinic_main.c
> @@ -1433,6 +1433,9 @@ static void hinic_remove(struct pci_dev *pdev)
>  
>  	hinic_free_intr_coalesce(nic_dev);
>  
> +	kfree(nic_dev->rss_indir_user);
> +	kfree(nic_dev->rss_hkey_user);
> +

I scanned the code and ... maybe I got this wrong ... but it looks like
nothing actually uses these fields?

If you look at hinic_ethtool.c, the buffers are allocated, data is copied into
them and then they are never used. hinic_get_rxfh seems to read the state
directly from the device ?

I wonder if the correct fix is to drop the buffers and the memcpys entirely
because they seem unnecessary and unused.

      reply	other threads:[~2026-07-20 13:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-20  9:11 [PATCH net] hinic: fix leak of ethtool RSS user configuration buffers Chenguang Zhao
2026-07-20 13:01 ` Joe Damato [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=al4cIYk8hEulreoI@devvm20253.cco0.facebook.com \
    --to=joe@dama.to \
    --cc=andrew+netdev@lunn.ch \
    --cc=cai.huoqing@linux.dev \
    --cc=chenguang.zhao@linux.dev \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=zhaochenguang@kylinos.cn \
    /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