Skip to contentSkip to conversation

pasemi_mac: ethtool get settings fix

PATCH In review Valentine Barshak 3 participants 8 messages Oct 1, 2009 – Oct 12, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pasemi_mac: ethtool get settings fix

Not all pasemi mac interfaces can have a phy attached. For example, XAUI has no phy and phydev is NULL for it. In this case ethtool get settings causes kernel crash. Fix it by returning -EOPNOTSUPP if there's no PHY attached.

---
 drivers/net/pasemi_mac_ethtool.c |    2 ++
 1 file changed, 2 insertions(+)
drivers/net/pasemi_mac_ethtool.c +2 -0
@@ -71,6 +71,8 @@ pasemi_mac_ethtool_get_settings(struct n
 	struct pasemi_mac *mac = netdev_priv(netdev);
 	struct phy_device *phydev = mac->phydev;
 
+	if (!phydev)
+		return -EOPNOTSUPP;
 	return phy_ethtool_gset(phydev, cmd);
 }
author
#1 lore raw

Resending pasemi_mac ethtool patches...

Quoted 25 lines · Valentine Barshak

Not all pasemi mac interfaces can have a phy attached. For example, XAUI has no phy and phydev is NULL for it. In this case ethtool get settings causes kernel crash. Fix it by returning -EOPNOTSUPP if there's no PHY attached.

---
 drivers/net/pasemi_mac_ethtool.c |    2 ++
 1 file changed, 2 insertions(+)
drivers/net/pasemi_mac_ethtool.c +2 -0
@@ -71,6 +71,8 @@ pasemi_mac_ethtool_get_settings(struct n
 	struct pasemi_mac *mac = netdev_priv(netdev);
 	struct phy_device *phydev = mac->phydev;
 
+	if (!phydev)
+		return -EOPNOTSUPP;
 	return phy_ethtool_gset(phydev, cmd);
 }
 

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev

#2 lore raw

PATCH 1/1 pasemi_mac: ethtool get settings fix

Not all pasemi mac interfaces can have a phy attached. For example, XAUI has no phy and phydev is NULL for it. In this case ethtool get settings causes kernel crash. Fix it by returning -EOPNOTSUPP if there's no PHY attached.

---
 drivers/net/pasemi_mac_ethtool.c |    3 +++
 1 file changed, 3 insertions(+)
drivers/net/pasemi_mac_ethtool.c +3 -0
diff -pruN linux-2.6.orig/drivers/net/pasemi_mac_ethtool.c linux-2.6/drivers/net/pasemi_mac_ethtool.c
@@ -71,6 +71,9 @@ pasemi_mac_ethtool_get_settings(struct n
 	struct pasemi_mac *mac = netdev_priv(netdev);
 	struct phy_device *phydev = mac->phydev;
 
+	if (!phydev)
+		return -EOPNOTSUPP;
+
 	return phy_ethtool_gset(phydev, cmd);
 }
Acked-by on v1 1/1
#3 lore raw

Weird, I see my address in the to: line but I never got a copy in my inbox.

Quoted 6 lines · Valentine Barshak

Not all pasemi mac interfaces can have a phy attached. For example, XAUI has no phy and phydev is NULL for it. In this case ethtool get settings causes kernel crash. Fix it by returning -EOPNOTSUPP if there's no PHY attached.

Quoted 21 lines
---
 drivers/net/pasemi_mac_ethtool.c |    3 +++
 1 file changed, 3 insertions(+)

diff -pruN linux-2.6.orig/drivers/net/pasemi_mac_ethtool.c linux-2.6/drivers/net/pasemi_mac_ethtool.c

drivers/net/pasemi_mac_ethtool.c +3 -0
@@ -71,6 +71,9 @@ pasemi_mac_ethtool_get_settings(struct n
 	struct pasemi_mac *mac = netdev_priv(netdev);
 	struct phy_device *phydev = mac->phydev;
 
+	if (!phydev)
+		return -EOPNOTSUPP;
+
 	return phy_ethtool_gset(phydev, cmd);
 }
 

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev

maintainer Applied
#4 lore raw

From: Olof Johansson <[email protected]>
Date: Tue, 6 Oct 2009 11:10:54 -0500

Quoted 11 lines

Weird, I see my address in the to: line but I never got a copy in my inbox.

Quoted 6 lines · Valentine Barshak

Not all pasemi mac interfaces can have a phy attached. For example, XAUI has no phy and phydev is NULL for it. In this case ethtool get settings causes kernel crash. Fix it by returning -EOPNOTSUPP if there's no PHY attached.

Applied to net-2.6, thanks!

#5 lore raw

PATCH 1/1 pasemi_mac: ethtool set settings support

In reply to Valentine

Add ethtool set settings to pasemi_mac_ethtool.

---
 drivers/net/pasemi_mac_ethtool.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/net/pasemi_mac_ethtool.c +14 -0
diff -pruN linux-2.6.orig/drivers/net/pasemi_mac_ethtool.c linux-2.6/drivers/net/pasemi_mac_ethtool.c
@@ -77,6 +77,19 @@ pasemi_mac_ethtool_get_settings(struct n
 	return phy_ethtool_gset(phydev, cmd);
 }
 
+static int
+pasemi_mac_ethtool_set_settings(struct net_device *netdev,
+			       struct ethtool_cmd *cmd)
+{
+	struct pasemi_mac *mac = netdev_priv(netdev);
+	struct phy_device *phydev = mac->phydev;
+
+	if (!phydev)
+		return -EOPNOTSUPP;
+
+	return phy_ethtool_sset(phydev, cmd);
+}
+
 static void
 pasemi_mac_ethtool_get_drvinfo(struct net_device *netdev,
 			       struct ethtool_drvinfo *drvinfo)
@@ -150,6 +163,7 @@ static void pasemi_mac_get_strings(struc
 
 const struct ethtool_ops pasemi_mac_ethtool_ops = {
 	.get_settings		= pasemi_mac_ethtool_get_settings,
+	.set_settings		= pasemi_mac_ethtool_set_settings,
 	.get_drvinfo		= pasemi_mac_ethtool_get_drvinfo,
 	.get_msglevel		= pasemi_mac_ethtool_get_msglevel,
 	.set_msglevel		= pasemi_mac_ethtool_set_msglevel,