[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20201031143619.7086-1-sbauer@blackbox.su>
Date: Sat, 31 Oct 2020 17:36:18 +0300
From: Sergej Bauer <sbauer@...ckbox.su>
To: kuba@...nel.org
Cc: sbauer@...ckbox.su,
Bryan Whitehead <bryan.whitehead@...rochip.com>,
Microchip Linux Driver Support <UNGLinuxDriver@...rochip.com>,
"David S. Miller" <davem@...emloft.net>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v2] fix for potential NULL pointer dereference with bare lan743x
Signed-off-by: Sergej Bauer <sbauer@...ckbox.su>
---
drivers/net/ethernet/microchip/lan743x_ethtool.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/microchip/lan743x_ethtool.c b/drivers/net/ethernet/microchip/lan743x_ethtool.c
index dcde496da7fb..ad38fc9e1468 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;
@@ -792,6 +794,7 @@ static int lan743x_ethtool_set_wol(struct net_device *netdev,
struct ethtool_wolinfo *wol)
{
struct lan743x_adapter *adapter = netdev_priv(netdev);
+ int ret;
adapter->wolopts = 0;
if (wol->wolopts & WAKE_UCAST)
@@ -809,9 +812,12 @@ static int lan743x_ethtool_set_wol(struct net_device *netdev,
device_set_wakeup_enable(&adapter->pdev->dev, (bool)wol->wolopts);
- phy_ethtool_set_wol(netdev->phydev, wol);
+ if (netdev->phydev)
+ ret = phy_ethtool_set_wol(netdev->phydev, wol);
+ else
+ ret = -EIO;
- return 0;
+ return ret;
}
#endif /* CONFIG_PM */
--
2.20.1
Powered by blists - more mailing lists