mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Fan Wu <12321260@zju.edu.cn>
To: Jacob Keller <jacob.e.keller@intel.com>
Cc: Fan Wu <fanwu01@zju.edu.cn>,
	netdev@vger.kernel.org, przemyslaw.kitszel@intel.com,
	Simon Horman <horms@kernel.org>,
	shenjian15@huawei.com, salil.mehta@huawei.com,
	dingtianhong@huawei.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH net] net: hip04: fix RX buffer leak on build_skb failure
Date: Wed, 15 Jul 2026 15:30:17 +0800	[thread overview]
Message-ID: <190A7669-E0EC-4257-B65E-817FFA1ACCDC@zju.edu.cn> (raw)
In-Reply-To: <a361aa28-7f55-4476-9072-aa392a34b735@intel.com>

Hi Jacob,

Thanks for the review. I agree this is a rare allocation-failure path.

The leak is nevertheless deterministic from the ownership contract and
the driver's control flow. __build_skb() documents that, on failure, it
returns NULL without freeing the caller-provided data.

hip04_rx_poll() currently jumps to refill before dma_unmap_single().
Refill then replaces rx_buf[rx_head] and rx_phys[rx_head], so the old
fragment and its streaming DMA mapping are no longer reachable. The
stop and free-ring paths only operate on entries still referenced by
those arrays.

The fix leaves the slot, descriptor, rx_head, and rx_cnt_remaining
unchanged, and returns budget. This tells NAPI that RX work remains
outstanding and retries build_skb() using the same buffer. The additional
skb_free_frag() handles the separate case where a replacement fragment
was allocated but dma_map_single() failed before it was installed.

I hope this clarifies why the failure path is a deterministic leak even
though I do not have a dynamic reproduction on HIP04 hardware.

Thanks,
Fan


  reply	other threads:[~2026-07-15  7:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-12 14:27 Fan Wu
2026-07-15  0:17 ` Jacob Keller
2026-07-15  7:30   ` Fan Wu [this message]
2026-07-15 16:51     ` Jacob Keller
2026-07-15 16:52 ` Jacob Keller

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=190A7669-E0EC-4257-B65E-817FFA1ACCDC@zju.edu.cn \
    --to=12321260@zju.edu.cn \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=dingtianhong@huawei.com \
    --cc=edumazet@google.com \
    --cc=fanwu01@zju.edu.cn \
    --cc=horms@kernel.org \
    --cc=jacob.e.keller@intel.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=salil.mehta@huawei.com \
    --cc=shenjian15@huawei.com \
    --cc=stable@vger.kernel.org \
    /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