mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jijie Shao <shaojijie@huawei.com>
To: <netdev-bot+sashiko@kernel.org>
Cc: <shaojijie@huawei.com>, <davem@davemloft.net>,
	<edumazet@kernel.org>, <kuba@kernel.org>, <pabeni@redhat.com>,
	<andrew+netdev@lunn.ch>, <shenjian15@huawei.com>,
	<liuyonglong@huawei.com>, <chenhao418@huawei.com>,
	<yangshuaisong@h-partners.com>, <ningwei15@huawei.com>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 net 2/4] net: hns3: fix page_pool leak in hns3_alloc_ring_memory error path
Date: Wed, 4 Nov 2026 19:51:02 +0800	[thread overview]
Message-ID: <87245a0b-2d33-49c6-a21b-9a316c50bef7@huawei.com> (raw)
In-Reply-To: <179370110712.488856.17112299707405359724@kernel.org>


on 2026/11/3 18:18, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found more severe
> issue(s) in other patches of this series. This mail is only an FYI, in case
> you want to address the nit picks below when you respin.
>
> Low priority / nit picks for your consideration:
>
> - [Low] The commit message says the new cleanup in
>    hns3_alloc_ring_memory()…
>
> --
>
> net: hns3: fix page_pool leak in hns3_alloc_ring_memory error path
>
> When hns3_alloc_ring_buffers() fails for an RX ring, the out_with_desc
> error path in hns3_alloc_ring_memory() frees the descriptor ring. It does
> not destroy the page_pool that hns3_alloc_page_pool() just created. This
> patch adds a guarded page_pool_destroy() to that error path.
>
>> Add page_pool_destroy() to the out_with_desc error path, guarded by
>> a NULL check, mirroring the cleanup done in hns3_free_ring_memory().
> [Severity: Low]
> This isn't a bug, but is hns3_free_ring_memory() the right name here? I
> can't find a function with that name under
> drivers/net/ethernet/hisilicon/hns3/.
>
> The only other RX page_pool_destroy() is in hns3_fini_ring(). That function
> calls hns3_free_desc() first and destroys the pool last:
>
> drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:hns3_fini_ring() {
> 	hns3_free_desc(ring);
> 	devm_kfree(ring_to_dev(ring), ring->desc_cb);
>      ...
> 	if (!HNAE3_IS_TX_RING(ring) && ring->page_pool) {
> 		page_pool_destroy(ring->page_pool);
> 		ring->page_pool = NULL;
> 	}
> }
>
> The new out_with_desc path does it in the opposite order. It destroys the
> pool and sets ring->page_pool to NULL, then calls hns3_free_desc().
>
> That order looks harmless today. By the time hns3_alloc_ring_buffers()
> returns an error, it has already detached every buffer it attached. Each
> desc_cb[i].dma is zero, so hns3_free_buffer_detach() returns early and
> never hands a page back to the NULL pool.
>
> Could the commit message name hns3_fini_ring() instead? It could also drop
> the word "mirroring", since the order differs.

Agreed, that function does not exist. Will rename to
hns3_fini_ring() and drop "mirroring" in v4, since the
destroy order differs (pool-then-desc here vs desc-then-pool
in hns3_fini_ring()). The opposite order is safe in this
error path because hns3_alloc_ring_buffers() has already
detached every buffer.



  reply	other threads:[~2026-11-04 11:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-30  9:56 [PATCH v3 net 0/4] net: hns3: fix multiple bugs in reset/error paths Jijie Shao
2026-10-30  9:56 ` [PATCH v3 net 1/4] net: hns3: fix vector resource leak in hns3_nic_alloc_vector_data Jijie Shao
2026-11-03 10:18   ` netdev-bot+sashiko
2026-11-04 11:49     ` Jijie Shao
2026-10-30  9:56 ` [PATCH v3 net 2/4] net: hns3: fix page_pool leak in hns3_alloc_ring_memory error path Jijie Shao
2026-11-03 10:18   ` netdev-bot+sashiko
2026-11-04 11:51     ` Jijie Shao [this message]
2026-10-30  9:56 ` [PATCH v3 net 3/4] net: hns3: fix interface stuck after OOM with full hardware rx queue Jijie Shao
2026-11-03 10:18   ` netdev-bot+sashiko
2026-11-04 12:03     ` Jijie Shao
2026-10-30  9:56 ` [PATCH v3 net 4/4] net: hns3: fix use-after-free in debugfs read during reset/unload Jijie Shao
2026-11-03 10:18   ` netdev-bot+sashiko
2026-11-04 12:29     ` Jijie Shao
2026-10-30 10:00 ` [PATCH v3 net 0/4] net: hns3: fix multiple bugs in reset/error paths netdev-bot+sinfo

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=87245a0b-2d33-49c6-a21b-9a316c50bef7@huawei.com \
    --to=shaojijie@huawei.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=chenhao418@huawei.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuyonglong@huawei.com \
    --cc=netdev-bot+sashiko@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=ningwei15@huawei.com \
    --cc=pabeni@redhat.com \
    --cc=shenjian15@huawei.com \
    --cc=yangshuaisong@h-partners.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®