From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752481AbcERBEz (ORCPT ); Tue, 17 May 2016 21:04:55 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:39154 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751842AbcERBEx (ORCPT ); Tue, 17 May 2016 21:04:53 -0400 Subject: Re: [PATCH 1/1] net: hns: avoid null pointer dereference To: Heinrich Schuchardt , "David S. Miller" References: <1463515275-9836-1-git-send-email-xypron.glpk@gmx.de> CC: Kejian Yan , Lisheng , Kenneth Lee , Andrew Lunn , Salil , Qianqian Xie , huangdaode , Chenny Xu , , From: Yisen Zhuang Message-ID: <573BBF87.4010101@huawei.com> Date: Wed, 18 May 2016 09:04:07 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <1463515275-9836-1-git-send-email-xypron.glpk@gmx.de> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.74.157.38] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090204.573BBF9A.00E1,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: ed374cea38de9f143990dd46f5a6e629 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Heinrich, This patch is fine to me. Thanks, Yisen 在 2016/5/18 4:01, Heinrich Schuchardt 写道: > In the statement > assert(priv || priv->ae_handle); > the right side of || is only evaluated if priv is null. > > Signed-off-by: Heinrich Schuchardt > --- > 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; > @@ -780,7 +780,7 @@ static int hns_set_coalesce(struct net_device *net_dev, > struct hnae_ae_ops *ops; > int ret; > > - assert(priv || priv->ae_handle); > + assert(priv && priv->ae_handle); > > ops = priv->ae_handle->dev->ops; > > @@ -1111,7 +1111,7 @@ void hns_get_regs(struct net_device *net_dev, struct ethtool_regs *cmd, > struct hns_nic_priv *priv = netdev_priv(net_dev); > struct hnae_ae_ops *ops; > > - assert(priv || priv->ae_handle); > + assert(priv && priv->ae_handle); > > ops = priv->ae_handle->dev->ops; > > @@ -1135,7 +1135,7 @@ static int hns_get_regs_len(struct net_device *net_dev) > struct hns_nic_priv *priv = netdev_priv(net_dev); > struct hnae_ae_ops *ops; > > - assert(priv || priv->ae_handle); > + assert(priv && priv->ae_handle); > > ops = priv->ae_handle->dev->ops; > if (!ops->get_regs_len) { >