All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vadim Fedorenko <vadim.fedorenko@linux.dev>
To: Ian Rogers <irogers@google.com>,
	Horatiu Vultur <horatiu.vultur@microchip.com>,
	Daniel Machon <daniel.machon@microchip.com>,
	UNGLinuxDriver@microchip.com, Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	llvm@lists.linux.dev, Elkin Cruz <elkin@google.com>
Subject: Re: [PATCH net v2] net: lan966x: Free skb when PTP TX timestamp request fails in xmit
Date: Wed, 2 Dec 2026 16:05:57 +0000	[thread overview]
Message-ID: <ced4c2ac-3deb-451c-82a4-0b2f96d734f2@linux.dev> (raw)
In-Reply-To: <20261201174325.1434854-1-irogers@google.com>

On 01/12/2026 17:43, Ian Rogers wrote:
> When all LAN966X_MAX_PTP_ID timestamp slots are in flight,
> lan966x_ptp_txtstamp_request() returns -EBUSY without queuing or freeing
> skb, and lan966x_port_xmit() returns that negative errno directly from
> .ndo_start_xmit. Because dev_xmit_complete() treats negative return
> values (< NET_XMIT_MASK) as packets already consumed by the driver, skb
> is never freed or requeued, leaking the sk_buff and its socket
> sk_wmem_alloc accounting (which can eventually stall the sending PTP
> socket once its send buffer fills).
> 
> Free skb with dev_kfree_skb_any(), account the drop with
> dev_core_stats_tx_dropped_inc(dev), and return NETDEV_TX_OK on failure.
> Using dev_core_stats_tx_dropped_inc() ensures the software drop is
> included by dev_get_stats() alongside lan966x_stats_get(), which reads
> hardware counters only and ignores dev->stats.
> 
> Discovered by compiling an x86_64 allyesconfig kernel with Clang's
> -Wimplicit-int-enum-cast and verified by code inspection of
> lan966x_ptp_txtstamp_request(), lan966x_port_xmit(), and
> dev_xmit_complete(); Gemini assisted with auditing the warning and
> drafting the patch and commit message. The issue was not triggered at
> runtime and the fix is compile-tested only (LLVM=1 W=1 -Werror) because
> Microchip LAN966x hardware is not available.
> 
> Fixes: 77eecf25bd9d ("net: lan966x: Update extraction/injection for timestamping")
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> 
> Notes:
>      v2:
>        - Use dev_core_stats_tx_dropped_inc(dev) instead of
>          dev->stats.tx_dropped++ so software drops are visible alongside
>          lan966x_stats_get() (Sashiko AI review, Daniel Machon).
>        - Drop the netdev_tx_t ret cleanup for fdma_xmit/lan966x_port_ifh_xmit
>          so Daniel can carry it in his upcoming PTP TX series (Daniel Machon).
>      
>      v1: https://lore.kernel.org/r/20261119170729.1524516-1-irogers@google.com
> 
>   drivers/net/ethernet/microchip/lan966x/lan966x_main.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
> index b8696fc7e9b9..d0cc10cc0507 100644
> --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
> +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
> @@ -404,8 +404,11 @@ static netdev_tx_t lan966x_port_xmit(struct sk_buff *skb,
>   
>   	if (port->lan966x->ptp && skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) {
>   		err = lan966x_ptp_txtstamp_request(port, skb);
> -		if (err)
> -			return err;
> +		if (err) {
> +			dev_kfree_skb_any(skb);
> +			dev_core_stats_tx_dropped_inc(dev);
> +			return NETDEV_TX_OK;
> +		}
>   
>   		lan966x_ifh_set_rew_op(ifh, LAN966X_SKB_CB(skb)->rew_op);
>   		lan966x_ifh_set_oam_type(ifh, LAN966X_SKB_CB(skb)->pdu_type);

Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>

      reply	other threads:[~2026-12-02 16:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 17:43 [PATCH net v2] net: lan966x: Free skb when PTP TX timestamp request fails in xmit Ian Rogers
2026-12-02 16:05 ` Vadim Fedorenko [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=ced4c2ac-3deb-451c-82a4-0b2f96d734f2@linux.dev \
    --to=vadim.fedorenko@linux.dev \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=daniel.machon@microchip.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=elkin@google.com \
    --cc=horatiu.vultur@microchip.com \
    --cc=irogers@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.