[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAk-MO-O9sjHQvDfCEuzJJPvUMXJTuRaCzrCkB0xc1DUfK8Aew@mail.gmail.com>
Date: Tue, 14 Apr 2015 19:30:03 +0300
From: Erez Shitrit <erezsh@....mellanox.co.il>
To: Honggang Li <honli@...hat.com>
Cc: Roland Dreier <roland@...nel.org>, sean.hefty@...el.com,
hal.rosenstock@...il.com, kaber@...sh.net, davem@...emloft.net,
Alex Estrin <alex.estrin@...el.com>,
Doug Ledford <dledford@...hat.com>, edumazet@...gle.com,
Erez Shitrit <erezsh@...lanox.com>, nicolas.dichtel@...nd.com,
maheshb@...gle.com, jbenc@...hat.com, ebiederm@...ssion.com,
elfring@...rs.sourceforge.net, f.fainelli@...il.com,
linux@...ck-us.net, andrew@...n.ch, sfeldma@...il.com,
alexander.h.duyck@...el.com,
"linux-rdma@...r.kernel.org" <linux-rdma@...r.kernel.org>,
linux-kernel@...r.kernel.org, netdev@...r.kernel.org
Subject: Re: [PATCH linux-next 1/4] infiniband/ipoib: fix possible NULL
pointer dereference in ipoib_get_iflink
On Tue, Apr 14, 2015 at 6:20 PM, Honggang Li <honli@...hat.com> wrote:
>
[...]
Hi,
> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
> index 657b89b..11ea6e2 100644
> --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
> +++ 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:
+ /* parent interface */
+ if (!test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags))
+ return dev->ifindex;
+
+ /* 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@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists