Skip to contentSkip to conversation

net: lan9303: Fix read error execution path

PATCH Applied Jerry Ray 4 participants 4 messages Dec 9, 2022 – Dec 12, 2022

Subsystems (3)
lore
Share & tools
lore

Jerry Ray

author
#0 lore raw

PATCH v2 1/1 net: lan9303: Fix read error execution path

This patch fixes an issue where a read failure of a port statistic counter will return unknown results. While it is highly unlikely the read will ever fail, it is much cleaner to return a zero for the stat count.

Fixes a1292595e006 ("net: dsa: add new DSA switch driver for the SMSC-LAN9303")

---
v1->v2:
corrected email header: net vs net-next, Added 1 maintainer, removed blank line.
No changes to the body of the patch.

---
 drivers/net/dsa/lan9303-core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/dsa/lan9303-core.c +3 -1
index 80f07bd20593..2e270b479143 100644
@@ -1005,9 +1005,11 @@ static void lan9303_get_ethtool_stats(struct dsa_switch *ds, int port,
 		ret = lan9303_read_switch_port(
 			chip, port, lan9303_mib[u].offset, &reg);
 
-		if (ret)
+		if (ret) {
 			dev_warn(chip->dev, "Reading status port %d reg %u failed\n",
 				 port, lan9303_mib[u].offset);
+			reg = 0;
+		}
 		data[u] = reg;
 	}
 }
Signature · 1 line
2.17.1
maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 10 lines · Jerry Ray

This patch fixes an issue where a read failure of a port statistic counter will return unknown results. While it is highly unlikely the read will ever fail, it is much cleaner to return a zero for the stat count.

Fixes a1292595e006 ("net: dsa: add new DSA switch driver for the SMSC-LAN9303")

---
v1->v2:
corrected email header: net vs net-next, Added 1 maintainer, removed blank line.

Actually it's not "net vs net-next", but rather, "nothing vs net-next". As you can see, the patchwork CI complains that "Target tree name [is] not specified in the subject".
https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/

Anyway, I think it's quite obvious for maintainers that it's a patch intended for the net.git tree, so there isn't a reason to resend this patch, just something to know and to do better in the future.

Quoted 2 lines

No changes to the body of the patch.
---

Reviewed-by on v2 1/1
#2 lore raw
In reply to Jerry Ray
Quoted 6 lines · Jerry Ray

This patch fixes an issue where a read failure of a port statistic counter will return unknown results. While it is highly unlikely the read will ever fail, it is much cleaner to return a zero for the stat count.

Fixes a1292595e006 ("net: dsa: add new DSA switch driver for the SMSC-LAN9303")
Signature · 1 line
Florian
#3 lore raw
In reply to Jerry Ray
This patch was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Fri, 9 Dec 2022 09:35:02 -0600 you wrote:

This patch fixes an issue where a read failure of a port statistic counter will return unknown results. While it is highly unlikely the read will ever fail, it is much cleaner to return a zero for the stat count.

Fixes a1292595e006 ("net: dsa: add new DSA switch driver for the SMSC-LAN9303")

[...]

Here is the summary with links:
- [v2] net: lan9303: Fix read error execution path

    https://git.kernel.org/netdev/net/c/8964916d2060

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html