From nobody Thu Dec 18 13:02:06 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8681C32772 for ; Tue, 23 Aug 2022 08:38:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345964AbiHWIiP (ORCPT ); Tue, 23 Aug 2022 04:38:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347504AbiHWIga (ORCPT ); Tue, 23 Aug 2022 04:36:30 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E50C977543; Tue, 23 Aug 2022 01:17:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A8952B81BF8; Tue, 23 Aug 2022 08:17:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0441EC433D6; Tue, 23 Aug 2022 08:17:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661242636; bh=5fy4IkzWjl1hfPLwkmTOIHwX1kHx3B1rb3uQ4pKYwEc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TlmPiX+M3fiMMfcs8P2CwxPtvb1WNYqLiLBj9oxm8r7gEhNGNmMOZxdsg5AFKHVSI foPUfSip99r8sU+EsYbnVgWBG5r2a4EhaiCKZaF4r8V+Ltge6ulvE/RyHpNGREP6YP hcHPnlWDvIveYxy79FEVUUKpH3mWEARMgkQmHBbk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gerhard Engleder , Jakub Kicinski Subject: [PATCH 5.19 150/365] tsnep: Fix tsnep_tx_unmap() error path usage Date: Tue, 23 Aug 2022 10:00:51 +0200 Message-Id: <20220823080124.506387071@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Gerhard Engleder commit b3bb8628bf64440065976c71e4ab09186c393597 upstream. If tsnep_tx_map() fails, then tsnep_tx_unmap() shall start at the write index like tsnep_tx_map(). This is different to the normal operation. Thus, add an additional parameter to tsnep_tx_unmap() to enable start at different positions for successful TX and failed TX. Fixes: 403f69bbdbad ("tsnep: Add TSN endpoint Ethernet MAC driver") Signed-off-by: Gerhard Engleder Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/engleder/tsnep_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/engleder/tsnep_main.c b/drivers/net/ether= net/engleder/tsnep_main.c index d98199f3414b..a5f7152a1716 100644 --- a/drivers/net/ethernet/engleder/tsnep_main.c +++ b/drivers/net/ethernet/engleder/tsnep_main.c @@ -340,14 +340,14 @@ static int tsnep_tx_map(struct sk_buff *skb, struct t= snep_tx *tx, int count) return 0; } =20 -static void tsnep_tx_unmap(struct tsnep_tx *tx, int count) +static void tsnep_tx_unmap(struct tsnep_tx *tx, int index, int count) { struct device *dmadev =3D tx->adapter->dmadev; struct tsnep_tx_entry *entry; int i; =20 for (i =3D 0; i < count; i++) { - entry =3D &tx->entry[(tx->read + i) % TSNEP_RING_SIZE]; + entry =3D &tx->entry[(index + i) % TSNEP_RING_SIZE]; =20 if (entry->len) { if (i =3D=3D 0) @@ -395,7 +395,7 @@ static netdev_tx_t tsnep_xmit_frame_ring(struct sk_buff= *skb, =20 retval =3D tsnep_tx_map(skb, tx, count); if (retval !=3D 0) { - tsnep_tx_unmap(tx, count); + tsnep_tx_unmap(tx, tx->write, count); dev_kfree_skb_any(entry->skb); entry->skb =3D NULL; =20 @@ -464,7 +464,7 @@ static bool tsnep_tx_poll(struct tsnep_tx *tx, int napi= _budget) if (skb_shinfo(entry->skb)->nr_frags > 0) count +=3D skb_shinfo(entry->skb)->nr_frags; =20 - tsnep_tx_unmap(tx, count); + tsnep_tx_unmap(tx, tx->read, count); =20 if ((skb_shinfo(entry->skb)->tx_flags & SKBTX_IN_PROGRESS) && (__le32_to_cpu(entry->desc_wb->properties) & --=20 2.37.2