linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fix for potential NULL pointer dereference with bare lan743x
@ 2020-10-29  0:28 Sergej Bauer
  2020-10-31  0:03 ` Jakub Kicinski
  0 siblings, 1 reply; 6+ messages in thread
From: Sergej Bauer @ 2020-10-29  0:28 UTC (permalink / raw)
  Cc: sbauer, Bryan Whitehead, Microchip Linux Driver Support,
	David S. Miller, Jakub Kicinski, netdev, linux-kernel

  This is just a minor fix which prevents a kernel NULL pointer
dereference when using phy-less lan743x.

Signed-off-by: Sergej Bauer <sbauer@blackbox.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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-11-01 20:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-29  0:28 [PATCH] fix for potential NULL pointer dereference with bare lan743x Sergej Bauer
2020-10-31  0:03 ` Jakub Kicinski
2020-10-31 14:36   ` [PATCH v2] " Sergej Bauer
     [not found]     ` <dabea6fc-2f2d-7864-721b-3c950265f764@web.de>
2020-11-01 19:54       ` [PATCH v2] lan743x: Fix for potential null pointer dereference Sergej Bauer
2020-11-01 20:38         ` Andrew Lunn
2020-11-01 20:54           ` Sergej Bauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).