summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/sun/sungem.c
diff options
context:
space:
mode:
authorPhilippe Reynes <tremyfr@gmail.com>2017-03-18 00:54:04 +0300
committerDavid S. Miller <davem@davemloft.net>2017-03-22 03:44:46 +0300
commite74bad6b015b732d8269a8ddfb303c9b33092722 (patch)
tree1d6d998d4cf73245d459d9098323bfa106c5262a /drivers/net/ethernet/sun/sungem.c
parentc5b71e633da381c299990341ec88694bd00ecad1 (diff)
downloadlinux-e74bad6b015b732d8269a8ddfb303c9b33092722.tar.xz
net: sun: sungem: rix a possible null dereference
The function gem_begin_auto_negotiation dereference the pointer ep before testing if it's null. This patch add a check on ep before dereferencing it. Fixes: 92552fdda557 ("net: sun: sungem: use new api ethtool_{get|set}_link_ksettings") Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Philippe Reynes <tremyfr@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/sun/sungem.c')
-rw-r--r--drivers/net/ethernet/sun/sungem.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/net/ethernet/sun/sungem.c b/drivers/net/ethernet/sun/sungem.c
index dbfca0466760..fa607d062cb3 100644
--- a/drivers/net/ethernet/sun/sungem.c
+++ b/drivers/net/ethernet/sun/sungem.c
@@ -1259,8 +1259,9 @@ static void gem_begin_auto_negotiation(struct gem *gp,
int duplex;
u32 advertising;
- ethtool_convert_link_mode_to_legacy_u32(&advertising,
- ep->link_modes.advertising);
+ if (ep)
+ ethtool_convert_link_mode_to_legacy_u32(
+ &advertising, ep->link_modes.advertising);
if (gp->phy_type != phy_mii_mdio0 &&
gp->phy_type != phy_mii_mdio1)