From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sergei Shtylyov Subject: Re: [Patch V4 net 01/11] net: hns3: add error handler for hns3_nic_init_vector_data() Date: Tue, 30 Oct 2018 12:11:13 +0300 Message-ID: References: <1540821261-55002-1-git-send-email-tanhuazhong@huawei.com> <1540821261-55002-2-git-send-email-tanhuazhong@huawei.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, linuxarm@huawei.com, salil.mehta@huawei.com, yisen.zhuang@huawei.com, lipeng321@huawei.com, linyunsheng@huawei.com To: Huazhong Tan , davem@davemloft.net Return-path: Received: from mail-lf1-f68.google.com ([209.85.167.68]:38796 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726479AbeJ3SD4 (ORCPT ); Tue, 30 Oct 2018 14:03:56 -0400 Received: by mail-lf1-f68.google.com with SMTP id p86so6040755lfg.5 for ; Tue, 30 Oct 2018 02:11:19 -0700 (PDT) In-Reply-To: <1540821261-55002-2-git-send-email-tanhuazhong@huawei.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 10/29/2018 4:54 PM, Huazhong Tan wrote: > When hns3_nic_init_vector_data() fails to map ring to vector, > it should cancel the netif_napi_add() that has been successfully > done and then exits. > > Fixes: 76ad4f0ee747 ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC") > Signed-off-by: Huazhong Tan > --- > drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c > index 32f3aca8..d9066c5 100644 > --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c > +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c > @@ -2821,7 +2821,7 @@ static int hns3_nic_init_vector_data(struct hns3_nic_priv *priv) > struct hnae3_handle *h = priv->ae_handle; > struct hns3_enet_tqp_vector *tqp_vector; > int ret = 0; > - u16 i; > + int i, j; > > hns3_nic_set_cpumask(priv); > > @@ -2868,13 +2868,19 @@ static int hns3_nic_init_vector_data(struct hns3_nic_priv *priv) > hns3_free_vector_ring_chain(tqp_vector, &vector_ring_chain); > > if (ret) > - return ret; > + goto map_ring_fail; > > netif_napi_add(priv->netdev, &tqp_vector->napi, > hns3_nic_common_poll, NAPI_POLL_WEIGHT); > } > > return 0; > + > +map_ring_fail: > + for (j = i - 1; j >= 0; j--) > + netif_napi_del(&priv->tqp_vector[j].napi); 'j' doesn't seem needed as well. [...] MBR, Sergei