Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754614AbbDNUm0 (ORCPT ); Tue, 14 Apr 2015 16:42:26 -0400 Received: from quartz.orcorp.ca ([184.70.90.242]:44561 "EHLO quartz.orcorp.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753737AbbDNUmO (ORCPT ); Tue, 14 Apr 2015 16:42:14 -0400 Date: Tue, 14 Apr 2015 14:41:33 -0600 From: Jason Gunthorpe To: Erez Shitrit Cc: Honggang Li , Roland Dreier , sean.hefty@intel.com, hal.rosenstock@gmail.com, kaber@trash.net, davem@davemloft.net, Alex Estrin , Doug Ledford , edumazet@google.com, Erez Shitrit , nicolas.dichtel@6wind.com, maheshb@google.com, jbenc@redhat.com, ebiederm@xmission.com, elfring@users.sourceforge.net, f.fainelli@gmail.com, linux@roeck-us.net, andrew@lunn.ch, sfeldma@gmail.com, alexander.h.duyck@intel.com, "linux-rdma@vger.kernel.org" , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH linux-next 1/4] infiniband/ipoib: fix possible NULL pointer dereference in ipoib_get_iflink Message-ID: <20150414204133.GJ7682@obsidianresearch.com> References: <1429024817-21561-1-git-send-email-honli@redhat.com> <1429024817-21561-2-git-send-email-honli@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Broken-Reverse-DNS: no host name found for IP address 10.0.0.183 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1501 Lines: 42 On Tue, Apr 14, 2015 at 07:30:03PM +0300, Erez Shitrit wrote: > > diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c > > index 657b89b..11ea6e2 100644 > > +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c > > @@ -846,7 +846,10 @@ static int ipoib_get_iflink(const struct net_device *dev) > > { > > struct ipoib_dev_priv *priv = netdev_priv(dev); > > > > - return priv->parent->ifindex; > > + if (priv && priv->parent) > > + return priv->parent->ifindex; > > + else > > + return 0; > This will make parent interface to return 0 instead of its own ifindex. > I would suggest write something like that: Agree > + /* parent interface */ > + if (!test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags)) > + return dev->ifindex; > + > + /* child/vlan interface */ > + if (!priv->parent) > + return -1; Like was said for other drivers, I can't see how parent can be null while IPOIB_FLAG_SUBINTERFACE is set. Drop the last if. Erez, you basically rewrote this, please make a proper patch with the Fixes and Reported-By credit for Honggang. Lets merge this through Dave M's tree right away. Thank you all Jason -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/