From: Sergej Bauer <sbauer@blackbox.su>
To: unlisted-recipients:; (no To-header on input)
Cc: sbauer@blackbox.su,
Bryan Whitehead <bryan.whitehead@microchip.com>,
Microchip Linux Driver Support <UNGLinuxDriver@microchip.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] fix for potential NULL pointer dereference with bare lan743x
Date: Thu, 29 Oct 2020 03:28:45 +0300 [thread overview]
Message-ID: <20201029002845.28984-1-sbauer@blackbox.su> (raw)
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
next reply other threads:[~2020-10-29 0:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-29 0:28 Sergej Bauer [this message]
2020-10-31 0:03 ` [PATCH] fix for potential NULL pointer dereference with bare lan743x 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201029002845.28984-1-sbauer@blackbox.su \
--to=sbauer@blackbox.su \
--cc=UNGLinuxDriver@microchip.com \
--cc=bryan.whitehead@microchip.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox