[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <063D6719AE5E284EB5DD2968C1650D6D5F4C22D9@AcuExch.aculab.com>
Date: Thu, 19 May 2016 11:14:58 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Heinrich Schuchardt' <xypron.glpk@....de>,
"David S. Miller" <davem@...emloft.net>
CC: Yisen Zhuang <Yisen.Zhuang@...wei.com>,
Kejian Yan <yankejian@...wei.com>,
Lisheng <lisheng011@...wei.com>,
Kenneth Lee <liguozhu@...wei.com>,
"Andrew Lunn" <andrew@...n.ch>, Salil <salil.mehta@...wei.com>,
Qianqian Xie <xieqianqian@...wei.com>,
huangdaode <huangdaode@...ilicon.com>,
Chenny Xu <chenny.xu@...wei.com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH 1/1] net: hns: avoid null pointer dereference
From: Heinrich Schuchardt
> Sent: 17 May 2016 21:01
> In the statement
> assert(priv || priv->ae_handle);
> the right side of || is only evaluated if priv is null.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@....de>
> ---
> drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
> b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
> index 3d746c8..834a50a 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
> @@ -720,7 +720,7 @@ static int hns_set_pauseparam(struct net_device *net_dev,
> struct hnae_handle *h;
> struct hnae_ae_ops *ops;
>
> - assert(priv || priv->ae_handle);
> + assert(priv && priv->ae_handle);
>
> h = priv->ae_handle;
> ops = h->dev->ops;
...
Personally I'd just delete the assert().
It is probably easier to debug the 'oops' from the NULL pointer dereference
that that of the assert().
If either value can be NULL (without a coding error) then you'd want to
return an error.
David
Powered by blists - more mailing lists