netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: mvneta: only do WoL speed down if the PHY is valid
@ 2020-05-21 14:19 Daniel González Cabanelas
  2020-05-21 15:19 ` Andrew Lunn
  0 siblings, 1 reply; 11+ messages in thread
From: Daniel González Cabanelas @ 2020-05-21 14:19 UTC (permalink / raw)
  To: netdev; +Cc: davem, thomas.petazzoni, andrew

Previous patch:
 "net: mvneta: speed down the PHY, if WoL used, to save energy"

was causing a NULL pointer dereference when ethernet switches are
connected to mvneta, because they aren't handled directly as PHYs.

Fix it by restricting the mentioned patch for the PHY detected cases.

Reported-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Daniel González Cabanelas <dgcbueu@gmail.com>
---
 drivers/net/ethernet/marvell/mvneta.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 41d2a0eac..f9170bc93 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -3567,8 +3567,9 @@ static void mvneta_start_dev(struct mvneta_port *pp)
 
 	phylink_start(pp->phylink);
 
-	/* We may have called phy_speed_down before */
-	phy_speed_up(pp->dev->phydev);
+	if(pp->dev->phydev)
+		/* We may have called phy_speed_down before */
+		phy_speed_up(pp->dev->phydev);
 
 	netif_tx_start_all_queues(pp->dev);
 }
@@ -3577,7 +3578,7 @@ static void mvneta_stop_dev(struct mvneta_port *pp)
 {
 	unsigned int cpu;
 
-	if (device_may_wakeup(&pp->dev->dev))
+	if (pp->dev->phydev && device_may_wakeup(&pp->dev->dev))
 		phy_speed_down(pp->dev->phydev, false);
 
 	phylink_stop(pp->phylink);
-- 
2.26.2





^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-06-24  9:29 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-21 14:19 [PATCH] net: mvneta: only do WoL speed down if the PHY is valid Daniel González Cabanelas
2020-05-21 15:19 ` Andrew Lunn
2020-05-21 15:26   ` Russell King - ARM Linux admin
2020-05-21 15:55     ` Andrew Lunn
2020-05-21 18:20       ` Russell King - ARM Linux admin
2020-05-22 23:10         ` David Miller
2020-05-21 15:55     ` Daniel González Cabanelas
2020-06-05  9:49       ` Russell King - ARM Linux admin
2020-06-07  0:25         ` Daniel González Cabanelas
2020-06-24  9:29           ` Russell King - ARM Linux admin
2020-05-21 15:55     ` Florian Fainelli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).