[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201029002845.28984-1-sbauer@blackbox.su>
Date: Thu, 29 Oct 2020 03:28:45 +0300
From: Sergej Bauer <sbauer@...ckbox.su>
To: unlisted-recipients:; (no To-header on input)
Cc: sbauer@...ckbox.su,
Bryan Whitehead <bryan.whitehead@...rochip.com>,
Microchip Linux Driver Support <UNGLinuxDriver@...rochip.com>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] fix for potential NULL pointer dereference with bare lan743x
This is just a minor fix which prevents a kernel NULL pointer
dereference when using phy-less lan743x.
Signed-off-by: Sergej Bauer <sbauer@...ckbox.su>
---
drivers/net/ethernet/microchip/lan743x_ethtool.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/microchip/lan743x_ethtool.c b/drivers/net/ethernet/microchip/lan743x_ethtool.c
index dcde496da7fb..354d72d550f2 100644
--- a/drivers/net/ethernet/microchip/lan743x_ethtool.c
+++ b/drivers/net/ethernet/microchip/lan743x_ethtool.c
@@ -780,7 +780,9 @@ static void lan743x_ethtool_get_wol(struct net_device *netdev,
wol->supported = 0;
wol->wolopts = 0;
- phy_ethtool_get_wol(netdev->phydev, wol);
+
+ if (netdev->phydev)
+ phy_ethtool_get_wol(netdev->phydev, wol);
wol->supported |= WAKE_BCAST | WAKE_UCAST | WAKE_MCAST |
WAKE_MAGIC | WAKE_PHY | WAKE_ARP;
@@ -793,6 +795,9 @@ static int lan743x_ethtool_set_wol(struct net_device *netdev,
{
struct lan743x_adapter *adapter = netdev_priv(netdev);
+ if (!netdev->phydev)
+ return -EIO;
+
adapter->wolopts = 0;
if (wol->wolopts & WAKE_UCAST)
adapter->wolopts |= WAKE_UCAST;
--
2.20.1
Powered by blists - more mailing lists