lkml.org 
[lkml]   [2015]   [Sep]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] net: phy: Handle postive return codes in phy_connect
Date
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


\
 
 \ /
  Last update: 2015-09-05 20:21    [W:0.052 / U:0.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site