Skip to contentSkip to conversation

net: mv643xx_eth: potential NULL dereference in probe()

PATCH Applied Dan Carpenter 4 participants 4 messages Nov 13, 2013 – Nov 14, 2013

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

PATCH 1/1 net: mv643xx_eth: potential NULL dereference in probe()

We assume that "mp->phy" can be NULL a couple lines before the dereference.

Fixes 1cce16d37d0f ('net: mv643xx_eth: Add missing phy_addr_set in DT mode')
drivers/net/ethernet/marvell/mv643xx_eth.c +2 -1
index 00cd36e..e7905d9 100644
@@ -2890,7 +2890,8 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
 					 PHY_INTERFACE_MODE_GMII);
 		if (!mp->phy)
 			err = -ENODEV;
-		phy_addr_set(mp, mp->phy->addr);
+		else
+			phy_addr_set(mp, mp->phy->addr);
 	} else if (pd->phy_addr != MV643XX_ETH_PHY_NONE) {
 		mp->phy = phy_scan(mp, pd->phy_addr);
 
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Dan Carpenter

We assume that "mp->phy" can be NULL a couple lines before the dereference.

Fixes 1cce16d37d0f ('net: mv643xx_eth: Add missing phy_addr_set in DT mode')
Quoted 15 lines
drivers/net/ethernet/marvell/mv643xx_eth.c +2 -1
index 00cd36e..e7905d9 100644
@@ -2890,7 +2890,8 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
  					 PHY_INTERFACE_MODE_GMII);
  		if (!mp->phy)
  			err = -ENODEV;
-		phy_addr_set(mp, mp->phy->addr);
+		else
+			phy_addr_set(mp, mp->phy->addr);
  	} else if (pd->phy_addr != MV643XX_ETH_PHY_NONE) {
  		mp->phy = phy_scan(mp, pd->phy_addr);