summaryrefslogtreecommitdiff
path: root/drivers/net
diff options
context:
space:
mode:
authorMichael Walle <michael@walle.cc>2022-03-29 01:03:50 +0300
committerPaolo Abeni <pabeni@redhat.com>2022-03-29 11:47:24 +0300
commitad7da1ce5749c0eb4f09dd7e5510123be56f10fb (patch)
treeb976080c4d478eceb538f851162b4121000b4318 /drivers/net
parent807ca64e154638c7540f3dfb48a2b9a8a58385d0 (diff)
downloadlinux-ad7da1ce5749c0eb4f09dd7e5510123be56f10fb.tar.xz
net: lan966x: fix kernel oops on ioctl when I/F is down
ioctls handled by phy_mii_ioctl() will cause a kernel oops when the interface is down. Fix it by making sure there is a PHY attached. Fixes: 735fec995b21 ("net: lan966x: Implement SIOCSHWTSTAMP and SIOCGHWTSTAMP") Signed-off-by: Michael Walle <michael@walle.cc> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Link: https://lore.kernel.org/r/20220328220350.3118969-1-michael@walle.cc Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ethernet/microchip/lan966x/lan966x_main.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
index e1bcb28039dc..1f8c67f0261b 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
@@ -408,6 +408,9 @@ static int lan966x_port_ioctl(struct net_device *dev, struct ifreq *ifr,
}
}
+ if (!dev->phydev)
+ return -ENODEV;
+
return phy_mii_ioctl(dev->phydev, ifr, cmd);
}