[PATCH] net: ethernet: Fix phy_set_max_speed by checking for NULL
From: Aditya Pakki
Date: Mon Mar 04 2019 - 18:36:40 EST
phy_device can be a NULL pointer which is further dereferenced
downstream in phy_set_max_speed. This patch avoids such a scenario.
Signed-off-by: Aditya Pakki <pakki001@xxxxxxx>
---
drivers/net/ethernet/broadcom/genet/bcmmii.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c
index aceb9b7b55bd..7eaaecb53aa2 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmmii.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c
@@ -213,6 +213,8 @@ int bcmgenet_mii_config(struct net_device *dev, bool init)
break;
case PHY_INTERFACE_MODE_MII:
+ if (!phydev)
+ return -ENODEV;
phy_name = "external MII";
phy_set_max_speed(phydev, SPEED_100);
bcmgenet_sys_writel(priv,
--
2.17.1