Skip to contentSkip to conversation

net: bcmasp: bug fixes for bcmasp

PATCH Applied Justin Chen 3 participants 5 messages Feb 15, 2024 – Feb 18, 2024

Subsystems (3)
lore
Share & tools
lore

Justin Chen

author maintainer
#0 lore raw

cover net: bcmasp: bug fixes for bcmasp

Fix two bugs.

- Indicate that PM is managed by mac to prevent double pm calls. This doesn't lead to a crash, but waste a noticable amount of time suspending/resuming.

- Sanity check for OOB write was off by one. Leading to a false error when using the full array.

Florian Fainelli (1):
net: bcmasp: Indicate MAC is in charge of PHY PM

Justin Chen (1):
net: bcmasp: Sanity check is off by one

 drivers/net/ethernet/broadcom/asp2/bcmasp.c      | 6 +++---
 drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 3 +++
 2 files changed, 6 insertions(+), 3 deletions(-)
Signature · 1 line
2.34.1
author maintainer
#1 lore raw

PATCH 1/2 net: bcmasp: Indicate MAC is in charge of PHY PM

From: Florian Fainelli <[email protected]>

Avoid the PHY library call unnecessarily into the suspend/resume functions by setting phydev->mac_managed_pm to true. The ASP driver essentially does exactly what mdio_bus_phy_resume() does.

Fixes 490cb412007d ("net: bcmasp: Add support for ASP2.0 Ethernet controller")
---
 drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +3 -0
index f59557b0cd51..6ad1366270f7 100644
@@ -1050,6 +1050,9 @@ static int bcmasp_netif_init(struct net_device *dev, bool phy_connect)
 			netdev_err(dev, "could not attach to PHY\n");
 			goto err_phy_disable;
 		}
+
+		/* Indicate that the MAC is responsible for PHY PM */
+		phydev->mac_managed_pm = true;
 	} else if (!intf->wolopts) {
 		ret = phy_resume(dev->phydev);
 		if (ret)
Signature · 1 line
2.34.1
author maintainer
#2 lore raw

PATCH 2/2 net: bcmasp: Sanity check is off by one

In reply to Justin Chen

A sanity check for OOB write is off by one leading to a false positive when the array is full.

Fixes 9b90aca97f6d ("net: ethernet: bcmasp: fix possible OOB write in bcmasp_netfilt_get_all_active()")
---
 drivers/net/ethernet/broadcom/asp2/bcmasp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/broadcom/asp2/bcmasp.c +3 -3
index 29b04a274d07..80245c65cc90 100644
@@ -535,9 +535,6 @@ int bcmasp_netfilt_get_all_active(struct bcmasp_intf *intf, u32 *rule_locs,
 	int j = 0, i;
 
 	for (i = 0; i < NUM_NET_FILTERS; i++) {
-		if (j == *rule_cnt)
-			return -EMSGSIZE;
-
 		if (!priv->net_filters[i].claimed ||
 		    priv->net_filters[i].port != intf->port)
 			continue;
@@ -547,6 +544,9 @@ int bcmasp_netfilt_get_all_active(struct bcmasp_intf *intf, u32 *rule_locs,
 		    priv->net_filters[i - 1].wake_filter)
 			continue;
 
+		if (j == *rule_cnt)
+			return -EMSGSIZE;
+
 		rule_locs[j++] = priv->net_filters[i].fs.location;
 	}
 
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 2/2
#3 lore raw

Re: [PATCH 2/2] net: bcmasp: Sanity check is off by one

Quoted 5 lines · Justin Chen

A sanity check for OOB write is off by one leading to a false positive when the array is full.

Fixes 9b90aca97f6d ("net: ethernet: bcmasp: fix possible OOB write in bcmasp_netfilt_get_all_active()")
Signature · 1 line
Florian
#4 lore raw
In reply to Justin Chen
This series was applied to netdev/net.git (main) by David S. Miller <[email protected]>:

Hello:

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

Quoted 10 lines · On Thu, 15 Feb 2024 10:27:30 -0800 you wrote:

Fix two bugs.

- Indicate that PM is managed by mac to prevent double pm calls. This doesn't lead to a crash, but waste a noticable amount of time suspending/resuming.

- Sanity check for OOB write was off by one. Leading to a false error when using the full array.

[...]

Here is the summary with links:
- [1/2] net: bcmasp: Indicate MAC is in charge of PHY PM

    https://git.kernel.org/netdev/net/c/5b76d928f8b7
  - [2/2] net: bcmasp: Sanity check is off by one
    https://git.kernel.org/netdev/net/c/f120e62e37f0

You are awesome, thank you!

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