Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1601766 > unrolled thread

[PATCH v2] net: sun: sungem: rix a possible null dereference

Started byPhilippe Reynes <tremyfr@gmail.com>
First post2017-03-15 23:00 +0100
Last post2017-03-17 05:00 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v2] net: sun: sungem: rix a possible null dereference Philippe Reynes <tremyfr@gmail.com> - 2017-03-15 23:00 +0100
    Re: [PATCH v2] net: sun: sungem: rix a possible null dereference David Miller <davem@davemloft.net> - 2017-03-17 05:00 +0100

#1601766 — [PATCH v2] net: sun: sungem: rix a possible null dereference

FromPhilippe Reynes <tremyfr@gmail.com>
Date2017-03-15 23:00 +0100
Subject[PATCH v2] net: sun: sungem: rix a possible null dereference
Message-ID<tlp7z-5du-5@gated-at.bofh.it>
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: 92552fdd557 ("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>
---
Chanelog:
v2:
- use Fixes tag (thanks Sergei Shtylyov)

 drivers/net/ethernet/sun/sungem.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/sun/sungem.c b/drivers/net/ethernet/sun/sungem.c
index dbfca04..fa607d0 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)
-- 
1.7.4.4

[toc] | [next] | [standalone]


#1603025

FromDavid Miller <davem@davemloft.net>
Date2017-03-17 05:00 +0100
Message-ID<tlRdw-8tS-7@gated-at.bofh.it>
In reply to#1601766
From: Philippe Reynes <tremyfr@gmail.com>
Date: Wed, 15 Mar 2017 22:51:13 +0100

> 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: 92552fdd557 ("net: sun: sungem: use new api

[davem@localhost net-next]$ git describe 92552fdd557
fatal: Not a valid object name 92552fdd557
[davem@localhost net-next]$

I don't know where you got that SHA1-ID, but it's not the one that
was actually used.

It is advised that you use Linus's or one of my GIT trees to find the
proper commit IDs.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web