From: Michael Welling <mwelling@ieee.org>
To: Florian Fainelli <f.fainelli@gmail.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Michael Welling <mwelling@ieee.org>
Subject: [PATCH] net: phy: Handle postive return codes in phy_connect
Date: Sat, 5 Sep 2015 13:01:29 -0500 [thread overview]
Message-ID: <1441476089-22108-1-git-send-email-mwelling@ieee.org> (raw)
The function phy_connect_direct can possibly return a positive
return code. Using ERR_PTR with a positive value can lead to
deferencing of an invalid pointer.
Signed-off-by: Michael Welling <mwelling@ieee.org>
---
drivers/net/phy/phy_device.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index c0f2111..a7e14a6 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -477,6 +477,9 @@ struct phy_device *phy_connect(struct net_device *dev, const char *bus_id,
phydev = to_phy_device(d);
rc = phy_connect_direct(dev, phydev, handler, interface);
+ if (rc > 0)
+ return ERR_PTR(-ENODEV);
+
if (rc)
return ERR_PTR(rc);
--
2.1.4
next reply other threads:[~2015-09-05 18:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-05 18:01 Michael Welling [this message]
2015-09-05 19:18 ` Andrew Lunn
2015-09-05 19:44 ` Michael Welling
2015-09-05 19:47 ` Andrew Lunn
2015-09-05 20:11 ` Florian Fainelli
2015-09-05 20:26 ` Michael Welling
2015-09-05 20:21 ` Michael Welling
2015-09-05 20:22 ` Andrew Lunn
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=1441476089-22108-1-git-send-email-mwelling@ieee.org \
--to=mwelling@ieee.org \
--cc=f.fainelli@gmail.com \
--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
all inboxes | Powered by JetHome®