* [PATCH net] net: phy: marvell10g: fix null pointer dereference
@ 2020-08-10 15:01 Marek Behún
2020-08-11 22:43 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Marek Behún @ 2020-08-10 15:01 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Marek Behún, Maxime Chevallier,
Andrew Lunn, Baruch Siach, Russell King
Commit c3e302edca24 ("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: c3e302edca24 ("net: phy: marvell10g: fix temperature sensor on 2110")
Signed-off-by: Marek Behún <marek.behun@nic.cz>
Cc: Maxime Chevallier <maxime.chevallier@bootlin.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Baruch Siach <baruch@tkos.co.il>
Cc: Russell King <rmk+kernel@armlinux.org.uk>
---
drivers/net/phy/marvell10g.c | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c
index a7610eb55f30f..1901ba277413d 100644
--- a/drivers/net/phy/marvell10g.c
+++ b/drivers/net/phy/marvell10g.c
@@ -208,13 +208,6 @@ static int mv3310_hwmon_config(struct phy_device *phydev, bool enable)
MV_V2_TEMP_CTRL_MASK, val);
}
-static void mv3310_hwmon_disable(void *data)
-{
- struct phy_device *phydev = data;
-
- mv3310_hwmon_config(phydev, false);
-}
-
static int mv3310_hwmon_probe(struct phy_device *phydev)
{
struct device *dev = &phydev->mdio.dev;
@@ -238,10 +231,6 @@ static int mv3310_hwmon_probe(struct phy_device *phydev)
if (ret)
return ret;
- ret = devm_add_action_or_reset(dev, mv3310_hwmon_disable, phydev);
- if (ret)
- return ret;
-
priv->hwmon_dev = devm_hwmon_device_register_with_info(dev,
priv->hwmon_name, phydev,
&mv3310_hwmon_chip_info, NULL);
@@ -426,6 +415,11 @@ static int mv3310_probe(struct phy_device *phydev)
return phy_sfp_probe(phydev, &mv3310_sfp_ops);
}
+static void mv3310_remove(struct phy_device *phydev)
+{
+ mv3310_hwmon_config(phydev, false);
+}
+
static int mv3310_suspend(struct phy_device *phydev)
{
return mv3310_power_down(phydev);
@@ -784,6 +778,7 @@ static struct phy_driver mv3310_drivers[] = {
.read_status = mv3310_read_status,
.get_tunable = mv3310_get_tunable,
.set_tunable = mv3310_set_tunable,
+ .remove = mv3310_remove,
},
{
.phy_id = MARVELL_PHY_ID_88E2110,
@@ -798,6 +793,7 @@ static struct phy_driver mv3310_drivers[] = {
.read_status = mv3310_read_status,
.get_tunable = mv3310_get_tunable,
.set_tunable = mv3310_set_tunable,
+ .remove = mv3310_remove,
},
};
--
2.26.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] net: phy: marvell10g: fix null pointer dereference
2020-08-10 15:01 [PATCH net] net: phy: marvell10g: fix null pointer dereference Marek Behún
@ 2020-08-11 22:43 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-08-11 22:43 UTC (permalink / raw)
To: marek.behun; +Cc: netdev, maxime.chevallier, andrew, baruch, rmk+kernel
From: Marek Behún <marek.behun@nic.cz>
Date: Mon, 10 Aug 2020 17:01:58 +0200
> Commit c3e302edca24 ("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: c3e302edca24 ("net: phy: marvell10g: fix temperature sensor on 2110")
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
Applied and queued up for -stable, thank you.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-08-11 22:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-10 15:01 [PATCH net] net: phy: marvell10g: fix null pointer dereference Marek Behún
2020-08-11 22:43 ` David Miller
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).