[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ddef9d62-ec9c-6df6-113a-e7b0a0bd2a05@cogentembedded.com>
Date: Tue, 30 Oct 2018 12:09:40 +0300
From: Sergei Shtylyov <sergei.shtylyov@...entembedded.com>
To: Huazhong Tan <tanhuazhong@...wei.com>, davem@...emloft.net
Cc: netdev@...r.kernel.org, linuxarm@...wei.com,
salil.mehta@...wei.com, yisen.zhuang@...wei.com,
lipeng321@...wei.com, linyunsheng@...wei.com
Subject: Re: [Patch V4 net 02/11] net: hns3: add error handler for
hns3_get_ring_config/hns3_queue_to_ring
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 <tanhuazhong@...wei.com>
> ---
> 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
Powered by blists - more mailing lists