提交 3e322474 编写于 作者: A Andrew Lunn 提交者: David S. Miller

net: phy: sfp: Fix unregistering of HWMON SFP device

A HWMON device is only registered is the SFP module supports the
diagnostic page and is complient to SFF8472. Don't unconditionally
unregister the hwmon device when the SFP module is remove, otherwise
we access data structures which don't exist.
Reported-by: NFlorian Fainelli <f.fainelli@gmail.com>
Fixes: 1323061a ("net: phy: sfp: Add HWMON support for module sensors")
Signed-off-by: NAndrew Lunn <andrew@lunn.ch>
Tested-by: NFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 77f2d753
......@@ -1098,8 +1098,11 @@ static int sfp_hwmon_insert(struct sfp *sfp)
static void sfp_hwmon_remove(struct sfp *sfp)
{
hwmon_device_unregister(sfp->hwmon_dev);
kfree(sfp->hwmon_name);
if (!IS_ERR_OR_NULL(sfp->hwmon_dev)) {
hwmon_device_unregister(sfp->hwmon_dev);
sfp->hwmon_dev = NULL;
kfree(sfp->hwmon_name);
}
}
#else
static int sfp_hwmon_insert(struct sfp *sfp)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册