From: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
To: Wei Fang <wei.fang@nxp.com>
Cc: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>,
Claudiu Manoil <claudiu.manoil@nxp.com>,
Vladimir Oltean <vladimir.oltean@nxp.com>,
Clark Wang <xiaoning.wang@nxp.com>,
"andrew+netdev@lunn.ch" <andrew+netdev@lunn.ch>,
"davem@davemloft.net" <davem@davemloft.net>,
"edumazet@google.com" <edumazet@google.com>,
"kuba@kernel.org" <kuba@kernel.org>,
"pabeni@redhat.com" <pabeni@redhat.com>,
Ioana Ciornei <ioana.ciornei@nxp.com>,
"Y.B. Lu" <yangbo.lu@nxp.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"imx@lists.linux.dev" <imx@lists.linux.dev>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH net 1/8] net: enetc: fix the off-by-one issue in enetc_map_tx_buffs()
Date: Tue, 18 Feb 2025 06:45:02 +0100 [thread overview]
Message-ID: <Z7QeXnBE0iBNFQYL@mev-dev.igk.intel.com> (raw)
In-Reply-To: <PAXPR04MB8510AA1D5B596B4382873A9F88FA2@PAXPR04MB8510.eurprd04.prod.outlook.com>
On Tue, Feb 18, 2025 at 02:11:12AM +0000, Wei Fang wrote:
> > > Fixes: d4fd0404c1c9 ("enetc: Introduce basic PF and VF ENETC ethernet
> > drivers")
> > > Cc: stable@vger.kernel.org
> > > Signed-off-by: Wei Fang <wei.fang@nxp.com>
> > > ---
> > > drivers/net/ethernet/freescale/enetc/enetc.c | 4 ++--
> > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c
> > b/drivers/net/ethernet/freescale/enetc/enetc.c
> > > index 6a6fc819dfde..f7bc2fc33a76 100644
> > > --- a/drivers/net/ethernet/freescale/enetc/enetc.c
> > > +++ b/drivers/net/ethernet/freescale/enetc/enetc.c
> > > @@ -372,13 +372,13 @@ static int enetc_map_tx_buffs(struct enetc_bdr
> > *tx_ring, struct sk_buff *skb)
> > > dma_err:
> > > dev_err(tx_ring->dev, "DMA map error");
> > >
> > > - do {
> > > + while (count--) {
> > > tx_swbd = &tx_ring->tx_swbd[i];
> > > enetc_free_tx_frame(tx_ring, tx_swbd);
> > > if (i == 0)
> > > i = tx_ring->bd_count;
> > > i--;
> > > - } while (count--);
> > > + };
> >
> > In enetc_lso_hw_offload() this is fixed by --count instead of changing
> > to while and count--, maybe follow this scheme, or event better call
> > helper function to fix in one place.
>
> The situation is slightly different in enetc_map_tx_buffs(), the count
> may be 0 when the error occurs. But in enetc_lso_hw_offload(), the
> count will not be 0 when the error occurs.
Right, didn't see that, sorry.
>
> >
> > The same problem is probably in enetc_map_tx_tso_buffs().
> >
>
> I think there is no such problem in enetc_map_tx_tso_buffs(),
> because the index 'i' has been increased before the error occurs,
> but the count is not increased, so the actual 'count' is count + 1.
>
But you can reach the error code jumping to label "err_chained_bd" where
both i and count is increased. Isn't it a problem?
BTW, not increasing i and count in one place looks like unnecessary
complication ;) .
Thanks,
Michal
next prev parent reply other threads:[~2025-02-18 5:48 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-17 9:38 [PATCH net 0/8] net: enetc: fix some known issues Wei Fang
2025-02-17 9:38 ` [PATCH net 1/8] net: enetc: fix the off-by-one issue in enetc_map_tx_buffs() Wei Fang
2025-02-17 13:11 ` Michal Swiatkowski
2025-02-18 2:11 ` Wei Fang
2025-02-18 5:45 ` Michal Swiatkowski [this message]
2025-02-18 6:08 ` Wei Fang
2025-02-17 17:10 ` Jakub Kicinski
2025-02-18 2:11 ` Wei Fang
2025-02-17 20:56 ` Claudiu Manoil
2025-02-18 2:02 ` Wei Fang
2025-02-18 9:02 ` Claudiu Manoil
2025-02-18 9:18 ` Wei Fang
2025-02-18 10:13 ` Claudiu Manoil
2025-02-17 9:39 ` [PATCH net 2/8] net: enetc: correct the tx_swbd statistics Wei Fang
2025-02-17 13:20 ` Michal Swiatkowski
2025-02-17 9:39 ` [PATCH net 3/8] net: enetc: correct the xdp_tx statistics Wei Fang
2025-02-17 9:39 ` [PATCH net 4/8] net: enetc: VFs do not support HWTSTAMP_TX_ONESTEP_SYNC Wei Fang
2025-02-17 9:39 ` [PATCH net 5/8] net: enetc: update UDP checksum when updating originTimestamp field Wei Fang
2025-02-17 9:39 ` [PATCH net 6/8] net: enetc: add missing enetc4_link_deinit() Wei Fang
2025-02-17 9:39 ` [PATCH net 7/8] net: enetc: remove the mm_lock from the ENETC v4 driver Wei Fang
2025-02-17 9:39 ` [PATCH net 8/8] net: enetc: correct the EMDIO base offset for ENETC v4 Wei Fang
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=Z7QeXnBE0iBNFQYL@mev-dev.igk.intel.com \
--to=michal.swiatkowski@linux.intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=imx@lists.linux.dev \
--cc=ioana.ciornei@nxp.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
--cc=vladimir.oltean@nxp.com \
--cc=wei.fang@nxp.com \
--cc=xiaoning.wang@nxp.com \
--cc=yangbo.lu@nxp.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;
as well as URLs for NNTP newsgroup(s).