Skip to content

Commit 1b8ef14

Browse files
elkablodavem330
authored andcommitted
net: phy: marvell10g: fix null pointer dereference
Commit c3e302e ("net: phy: marvell10g: fix temperature sensor on 2110") added a check for PHY ID via phydev->drv->phy_id in a function which is called by devres at a time when phydev->drv is already set to null by phy_remove function. This null pointer dereference can be triggered via SFP subsystem with a SFP module containing this Marvell PHY. When the SFP interface is put down, the SFP subsystem removes the PHY. Fixes: c3e302e ("net: phy: marvell10g: fix temperature sensor on 2110") Signed-off-by: Marek Behún <[email protected]> Cc: Maxime Chevallier <[email protected]> Cc: Andrew Lunn <[email protected]> Cc: Baruch Siach <[email protected]> Cc: Russell King <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0f5907a commit 1b8ef14

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

drivers/net/phy/marvell10g.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,6 @@ static int mv3310_hwmon_config(struct phy_device *phydev, bool enable)
208208
MV_V2_TEMP_CTRL_MASK, val);
209209
}
210210

211-
static void mv3310_hwmon_disable(void *data)
212-
{
213-
struct phy_device *phydev = data;
214-
215-
mv3310_hwmon_config(phydev, false);
216-
}
217-
218211
static int mv3310_hwmon_probe(struct phy_device *phydev)
219212
{
220213
struct device *dev = &phydev->mdio.dev;
@@ -238,10 +231,6 @@ static int mv3310_hwmon_probe(struct phy_device *phydev)
238231
if (ret)
239232
return ret;
240233

241-
ret = devm_add_action_or_reset(dev, mv3310_hwmon_disable, phydev);
242-
if (ret)
243-
return ret;
244-
245234
priv->hwmon_dev = devm_hwmon_device_register_with_info(dev,
246235
priv->hwmon_name, phydev,
247236
&mv3310_hwmon_chip_info, NULL);
@@ -426,6 +415,11 @@ static int mv3310_probe(struct phy_device *phydev)
426415
return phy_sfp_probe(phydev, &mv3310_sfp_ops);
427416
}
428417

418+
static void mv3310_remove(struct phy_device *phydev)
419+
{
420+
mv3310_hwmon_config(phydev, false);
421+
}
422+
429423
static int mv3310_suspend(struct phy_device *phydev)
430424
{
431425
return mv3310_power_down(phydev);
@@ -784,6 +778,7 @@ static struct phy_driver mv3310_drivers[] = {
784778
.read_status = mv3310_read_status,
785779
.get_tunable = mv3310_get_tunable,
786780
.set_tunable = mv3310_set_tunable,
781+
.remove = mv3310_remove,
787782
},
788783
{
789784
.phy_id = MARVELL_PHY_ID_88E2110,
@@ -798,6 +793,7 @@ static struct phy_driver mv3310_drivers[] = {
798793
.read_status = mv3310_read_status,
799794
.get_tunable = mv3310_get_tunable,
800795
.set_tunable = mv3310_set_tunable,
796+
.remove = mv3310_remove,
801797
},
802798
};
803799

0 commit comments

Comments
 (0)