Skip to contentSkip to conversation

net: dsa: mv88e6xxx: Fix off by in one in mv88e6185_phylink_get_caps()

PATCH Applied Dan Carpenter 3 participants 4 messages Feb 7, 2022

Subsystems (5)
lore
Share & tools
lore
#1 lore raw

PATCH 2/2 net: dsa: mv88e6xxx: Unlock on error in mv88e6xxx_port_bridge_join()

In reply to Dan Carpenter

Call mv88e6xxx_reg_unlock(chip) before returning on this error path.

Fixes 7af4a361a62f ("net: dsa: mv88e6xxx: Improve isolation of standalone ports")
---
 drivers/net/dsa/mv88e6xxx/chip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/mv88e6xxx/chip.c +1 -1
index 192a7688b4df..c54649c4c3a0 100644
@@ -2602,7 +2602,7 @@ static int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port,
 
 	err = mv88e6xxx_port_set_map_da(chip, port, true);
 	if (err)
-		return err;
+		goto unlock;
 
 	err = mv88e6xxx_port_commit_pvid(chip, port);
 	if (err)
Signature · 1 line
2.20.1
#0 lore raw

PATCH 1/2 net: dsa: mv88e6xxx: Fix off by in one in mv88e6185_phylink_get_caps()

The <= ARRAY_SIZE() needs to be < ARRAY_SIZE() to prevent an out of bounds error.

Fixes d4ebf12bcec4 ("net: dsa: mv88e6xxx: populate supported_interfaces and mac_capabilities")
---
 drivers/net/dsa/mv88e6xxx/chip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/mv88e6xxx/chip.c +1 -1
index 7670796c2aa1..192a7688b4df 100644
@@ -585,7 +585,7 @@ static void mv88e6185_phylink_get_caps(struct mv88e6xxx_chip *chip, int port,
 {
 	u8 cmode = chip->ports[port].cmode;
 
-	if (cmode <= ARRAY_SIZE(mv88e6185_phy_interface_modes) &&
+	if (cmode < ARRAY_SIZE(mv88e6185_phy_interface_modes) &&
 	    mv88e6185_phy_interface_modes[cmode])
 		__set_bit(mv88e6185_phy_interface_modes[cmode],
 			  config->supported_interfaces);
Signature · 1 line
2.20.1
Reviewed-by on v1 1/2
#2 lore raw
Quoted 5 lines · Dan Carpenter

The <= ARRAY_SIZE() needs to be < ARRAY_SIZE() to prevent an out of bounds error.

Fixes d4ebf12bcec4 ("net: dsa: mv88e6xxx: populate supported_interfaces and mac_capabilities")

Good catch, thanks.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
#3 lore raw
In reply to Dan Carpenter
This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:

Quoted 8 lines · On Mon, 7 Feb 2022 11:22:53 +0300 you wrote:

The <= ARRAY_SIZE() needs to be < ARRAY_SIZE() to prevent an out of bounds error.

Fixes d4ebf12bcec4 ("net: dsa: mv88e6xxx: populate supported_interfaces and mac_capabilities")
---
 drivers/net/dsa/mv88e6xxx/chip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Here is the summary with links:
- [1/2,net-next] net: dsa: mv88e6xxx: Fix off by in one in mv88e6185_phylink_get_caps()

    https://git.kernel.org/netdev/net-next/c/dde41a697331
  - [2/2,net-next] net: dsa: mv88e6xxx: Unlock on error in mv88e6xxx_port_bridge_join()
    https://git.kernel.org/netdev/net-next/c/ff62433883b3

You are awesome, thank you!

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