aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2013-02-07 15:18:34 +0000
committerGabor Juhos <juhosg@openwrt.org>2013-02-07 15:18:34 +0000
commitc32d96d9e643452badd97a4edb2bb41a70d8ea60 (patch)
treee652b02c08a6b8f3192a31ad77b102e3cde2ad5b /target/linux/generic
parentbabed81891ac2b751613176e910db10190121aea (diff)
downloadupstream-c32d96d9e643452badd97a4edb2bb41a70d8ea60.tar.gz
upstream-c32d96d9e643452badd97a4edb2bb41a70d8ea60.tar.bz2
upstream-c32d96d9e643452badd97a4edb2bb41a70d8ea60.zip
generic: mvswitch: add detach callback
Use the detach callback to disable packet mangling to avoid possible NULL pointer dereference. Compile tested only. Signed-off-by: Gabor Juhos <juhosg@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@35512 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/generic')
-rw-r--r--target/linux/generic/files/drivers/net/phy/mvswitch.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/mvswitch.c b/target/linux/generic/files/drivers/net/phy/mvswitch.c
index d754951aca..af73ec22a0 100644
--- a/target/linux/generic/files/drivers/net/phy/mvswitch.c
+++ b/target/linux/generic/files/drivers/net/phy/mvswitch.c
@@ -348,16 +348,26 @@ mvswitch_config_aneg(struct phy_device *phydev)
}
static void
-mvswitch_remove(struct phy_device *pdev)
+mvswitch_detach(struct phy_device *pdev)
{
struct mvswitch_priv *priv = to_mvsw(pdev);
struct net_device *dev = pdev->attached_dev;
+ if (!dev)
+ return;
+
dev->phy_ptr = NULL;
dev->eth_mangle_rx = NULL;
dev->eth_mangle_tx = NULL;
dev->features = priv->orig_features;
dev->priv_flags &= ~IFF_NO_IP_ALIGN;
+}
+
+static void
+mvswitch_remove(struct phy_device *pdev)
+{
+ struct mvswitch_priv *priv = to_mvsw(pdev);
+
kfree(priv);
}
@@ -399,6 +409,7 @@ static struct phy_driver mvswitch_driver = {
.features = PHY_BASIC_FEATURES,
.probe = &mvswitch_probe,
.remove = &mvswitch_remove,
+ .detach = &mvswitch_detach,
.config_init = &mvswitch_config_init,
.config_aneg = &mvswitch_config_aneg,
.read_status = &mvswitch_read_status,