netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Horatiu Vultur <horatiu.vultur@microchip.com>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	"David S . Miller" <davem@davemloft.net>,
	Sasha Levin <sashal@kernel.org>,
	netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 4.19 24/32] net: mscc: fix in frame extraction
Date: Mon,  2 Mar 2020 21:48:43 -0500	[thread overview]
Message-ID: <20200303024851.10054-24-sashal@kernel.org> (raw)
In-Reply-To: <20200303024851.10054-1-sashal@kernel.org>

From: Horatiu Vultur <horatiu.vultur@microchip.com>

[ Upstream commit a81541041ceb55bcec9a8bb8ad3482263f0a205a ]

Each extracted frame on Ocelot has an IFH. The frame and IFH are extracted
by reading chuncks of 4 bytes from a register.

In case the IFH and frames were read corretly it would try to read the next
frame. In case there are no more frames in the queue, it checks if there
were any previous errors and in that case clear the queue. But this check
will always succeed also when there are no errors. Because when extracting
the IFH the error is checked against 4(number of bytes read) and then the
error is set only if the extraction of the frame failed. So in a happy case
where there are no errors the err variable is still 4. So it could be
a case where after the check that there are no more frames in the queue, a
frame will arrive in the queue but because the error is not reseted, it
would try to flush the queue. So the frame will be lost.

The fix consist in resetting the error after reading the IFH.

Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/mscc/ocelot_board.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/ethernet/mscc/ocelot_board.c b/drivers/net/ethernet/mscc/ocelot_board.c
index 3cdf63e35b53b..4054cf9db8181 100644
--- a/drivers/net/ethernet/mscc/ocelot_board.c
+++ b/drivers/net/ethernet/mscc/ocelot_board.c
@@ -105,6 +105,14 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg)
 		if (err != 4)
 			break;
 
+		/* At this point the IFH was read correctly, so it is safe to
+		 * presume that there is no error. The err needs to be reset
+		 * otherwise a frame could come in CPU queue between the while
+		 * condition and the check for error later on. And in that case
+		 * the new frame is just removed and not processed.
+		 */
+		err = 0;
+
 		ocelot_parse_ifh(ifh, &info);
 
 		dev = ocelot->ports[info.port]->dev;
-- 
2.20.1


  parent reply	other threads:[~2020-03-03  2:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200303024851.10054-1-sashal@kernel.org>
2020-03-03  2:48 ` [PATCH AUTOSEL 4.19 04/32] selftests: fix too long argument Sasha Levin
2020-03-03  2:48 ` [PATCH AUTOSEL 4.19 13/32] selftests: forwarding: use proto icmp for {gretap, ip6gretap}_mac testing Sasha Levin
2020-03-03  2:48 ` [PATCH AUTOSEL 4.19 14/32] net: atlantic: fix use after free kasan warn Sasha Levin
2020-03-03  2:48 ` [PATCH AUTOSEL 4.19 15/32] net: atlantic: fix potential error handling Sasha Levin
2020-03-03  2:48 ` [PATCH AUTOSEL 4.19 16/32] net: phy: restore mdio regs in the iproc mdio driver Sasha Levin
2020-03-03  2:48 ` [PATCH AUTOSEL 4.19 17/32] net: dsa: b53: Ensure the default VID is untagged Sasha Levin
2020-03-03  2:48 ` [PATCH AUTOSEL 4.19 18/32] net: ks8851-ml: Remove 8-bit bus accessors Sasha Levin
2020-03-03  2:48 ` [PATCH AUTOSEL 4.19 19/32] net: ks8851-ml: Fix 16-bit data access Sasha Levin
2020-03-03  2:48 ` [PATCH AUTOSEL 4.19 20/32] net: ks8851-ml: Fix 16-bit IO operation Sasha Levin
2020-03-03  2:48 ` Sasha Levin [this message]
2020-03-03  2:48 ` [PATCH AUTOSEL 4.19 28/32] nfc: pn544: Fix occasional HW initialization failure Sasha Levin
2020-03-03  2:48 ` [PATCH AUTOSEL 4.19 29/32] ice: Don't tell the OS that link is going down Sasha Levin
2020-03-03  2:48 ` [PATCH AUTOSEL 4.19 32/32] net: thunderx: workaround BGX TX Underflow issue Sasha Levin

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=20200303024851.10054-24-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=davem@davemloft.net \
    --cc=horatiu.vultur@microchip.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).