From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sergei Shtylyov Subject: Re: [Patch V4 net 02/11] net: hns3: add error handler for hns3_get_ring_config/hns3_queue_to_ring Date: Tue, 30 Oct 2018 12:09:40 +0300 Message-ID: References: <1540821261-55002-1-git-send-email-tanhuazhong@huawei.com> <1540821261-55002-3-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-lj1-f194.google.com ([209.85.208.194]:41222 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726479AbeJ3SC0 (ORCPT ); Tue, 30 Oct 2018 14:02:26 -0400 Received: by mail-lj1-f194.google.com with SMTP id z80-v6so4518516ljb.8 for ; Tue, 30 Oct 2018 02:09:49 -0700 (PDT) In-Reply-To: <1540821261-55002-3-git-send-email-tanhuazhong@huawei.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: Hello! On 10/29/2018 4:54 PM, Huazhong Tan wrote: > When hns3_get_ring_config()/hns3_queue_to_ring() failed during resetting, > the allocated memory has not been freed before hns3_get_ring_config() and > hns3_queue_to_ring() return. So this patch fixes the buffer not freeing > problem during resetting. > > 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 | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c > index d9066c5..6f0fd62 100644 > --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c > +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c [...] > @@ -3047,7 +3049,7 @@ static int hns3_get_ring_config(struct hns3_nic_priv *priv) > { > struct hnae3_handle *h = priv->ae_handle; > struct pci_dev *pdev = h->pdev; > - int i, ret; > + int i, j, ret; > > priv->ring_data = devm_kzalloc(&pdev->dev, > array3_size(h->kinfo.num_tqps, > @@ -3065,6 +3067,12 @@ static int hns3_get_ring_config(struct hns3_nic_priv *priv) > > return 0; > err: > + for (j = i - 1; j >= 0; j--) { As is with the other patch, you don't need 'j' here. > + devm_kfree(priv->dev, priv->ring_data[j].ring); > + devm_kfree(priv->dev, > + priv->ring_data[j + h->kinfo.num_tqps].ring); > + } > + > devm_kfree(&pdev->dev, priv->ring_data); > return ret; > } MBR, Sergei