linux-stable/net/dsa
Vladimir Oltean 87803141fb net: dsa: fix error code getting shifted with 4 in dsa_slave_get_sset_count
[ Upstream commit b94cbc909f ]

DSA implements a bunch of 'standardized' ethtool statistics counters,
namely tx_packets, tx_bytes, rx_packets, rx_bytes. So whatever the
hardware driver returns in .get_sset_count(), we need to add 4 to that.

That is ok, except that .get_sset_count() can return a negative error
code, for example:

b53_get_sset_count
-> phy_ethtool_get_sset_count
   -> return -EIO

-EIO is -5, and with 4 added to it, it becomes -1, aka -EPERM. One can
imagine that certain error codes may even become positive, although
based on code inspection I did not see instances of that.

Check the error code first, if it is negative return it as-is.

Based on a similar patch for dsa_master_get_strings from Dan Carpenter:
https://patchwork.kernel.org/project/netdevbpf/patch/YJaSe3RPgn7gKxZv@mwanda/

Fixes: 91da11f870 ("net: Distributed Switch Architecture protocol support")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-06-03 08:59:12 +02:00
..
dsa.c net: dsa: add GRO support via gro_cells 2021-03-11 14:06:48 +01:00
dsa2.c net: dsa: call teardown method on probe failure 2021-02-17 10:35:19 +01:00
dsa_priv.h net: dsa: add GRO support via gro_cells 2021-03-11 14:06:48 +01:00
Kconfig net: dsa: add GRO support via gro_cells 2021-03-11 14:06:48 +01:00
Makefile net: dsa: microchip: remove NET_DSA_TAG_KSZ_COMMON 2019-09-12 11:36:12 +01:00
master.c net: dsa: fix a crash if ->get_sset_count() fails 2021-06-03 08:59:07 +02:00
port.c net: dsa: Don't instantiate phylink for CPU/DSA ports unless needed 2020-03-18 07:17:47 +01:00
slave.c net: dsa: fix error code getting shifted with 4 in dsa_slave_get_sset_count 2021-06-03 08:59:12 +02:00
switch.c net: dsa: program VLAN on CPU port from slave 2019-08-27 20:17:28 -07:00
tag_8021q.c net: dsa: tag_8021q: replace dsa_8021q_remove_header with __skb_vlan_pop 2020-04-01 11:01:34 +02:00
tag_brcm.c net: dsa: Fix duplicate frames flooded by learning 2020-04-01 11:01:33 +02:00
tag_dsa.c dsa: Cleanup unneeded table and make tag structures static 2019-04-28 19:41:01 -04:00
tag_edsa.c dsa: Allow forwarding of redirected IGMP traffic 2020-09-23 12:40:33 +02:00
tag_gswip.c net: dsa: tag_gswip: fix typo in tagger name 2020-01-23 08:22:52 +01:00
tag_ksz.c net: dsa: ksz: Add KSZ8795 tag code 2019-07-30 15:12:50 -07:00
tag_lan9303.c dsa: Cleanup unneeded table and make tag structures static 2019-04-28 19:41:01 -04:00
tag_mtk.c net: dsa: tag_mtk: fix 802.1ad VLAN egress 2021-03-20 10:39:47 +01:00
tag_qca.c net: dsa: tag_qca: Make sure there is headroom for tag 2020-02-24 08:36:22 +01:00
tag_sja1105.c net: dsa: tag_8021q: replace dsa_8021q_remove_header with __skb_vlan_pop 2020-04-01 11:01:34 +02:00
tag_trailer.c dsa: Cleanup unneeded table and make tag structures static 2019-04-28 19:41:01 -04:00