net: sun: sungem: rix a possible null dereference
authorPhilippe Reynes <tremyfr@gmail.com>
Fri, 17 Mar 2017 21:54:04 +0000 (22:54 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 22 Mar 2017 00:44:46 +0000 (17:44 -0700)
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>
drivers/net/ethernet/sun/sungem.c

index dbfca04667603af7f6f5bff36ba4372b09b81833..fa607d062cb3130eff15295f61a8efce7c6a969c 100644 (file)
@@ -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)