Re: [PATCH linux-next 1/4] infiniband/ipoib: fix possible NULL pointer dereference in ipoib_get_iflink

From: Honggang LI
Date: Wed Apr 15 2015 - 02:57:51 EST



There was network accident in the office. I can't find this email in
public mailing list. So, I reset it. If you had recived this, please
ignore it.

thanks

On Wed, Apr 15, 2015 at 01:16:40PM +0800, Honggang LI wrote:
> On Tue, Apr 14, 2015 at 07:30:03PM +0300, Erez Shitrit wrote:
> > > @@ -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:
> >
> > + /* parent interface */
> > + if (!test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags))
> > + return dev->ifindex;
> > +
>
> Hi, Erez
>
> Sorry for delay of reply. It was about 01:00 in the morning, so I
> went into bed. And thank you for the suggestion. You are right. After
> insert some printk statements in the driver, I confirmed it.
>
> ---------------------- console log --------------------
> ipoib_get_iflink: priv = ffff880275e487c0, priv->parent = (null), priv->flags = 0x20f, dev = ffff880275e48000, dev->name = qib_ib1
> qib_ib1, test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags) = 0
> qib_ib1, idev->ifindex = 14
>
> ipoib_get_iflink: priv = ffff8802765d27c0, priv->parent = (null), priv->flags = 0x20f, dev = ffff8802765d2000, dev->name = qib_ib2
> qib_ib2, test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags) = 0
> qib_ib2, idev->ifindex = 15
>
> ipoib_get_iflink: priv = ffff8804741a47c0, priv->parent = ffff880275e48000, priv->flags = 0x224, dev = ffff8804741a4000, dev->name = qib_ib1.8003
> qib_ib1.8003, test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags) = 1
> qib_ib1.8003, idev->ifindex = 16
>
> ---------------------- console log --------------------
>
> I will rewrite the patch.
>
> > + /* child/vlan interface */
> > + if (!priv->parent)
> > + return -1;
> > +
> > return priv->parent->ifindex;
> >
> > Thanks,
> > Erez.
> >
> > > }
> > >
> > > static u32 ipoib_addr_hash(struct ipoib_neigh_hash *htbl, u8 *daddr)
> > > --
> > > 1.8.3.1
> > >
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/