]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
net: hns3: fix a memory leak issue for hclge_map_unmap_ring_to_vf_vector
authorHuazhong Tan <tanhuazhong@huawei.com>
Tue, 28 May 2019 09:03:02 +0000 (17:03 +0800)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 14 Feb 2020 05:29:37 +0000 (00:29 -0500)
BugLink: https://bugs.launchpad.net/bugs/1863019
[ Upstream commit 49f971bd308571fe466687227130a7082b662d0e ]

When hclge_bind_ring_with_vector() fails,
hclge_map_unmap_ring_to_vf_vector() returns the error
directly, so nobody will free the memory allocated by
hclge_get_ring_chain_from_mbx().

So hclge_free_vector_ring_chain() should be called no matter
hclge_bind_ring_with_vector() fails or not.

Fixes: 84e095d64ed9 ("net: hns3: Change PF to add ring-vect binding & resetQ to mailbox")
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c

index a1de451a85dfc309e2e43c5de9b6760449c454f5..2301d4b2f5e87bfac9cbdbad0ab46c19355199b4 100644 (file)
@@ -192,12 +192,10 @@ static int hclge_map_unmap_ring_to_vf_vector(struct hclge_vport *vport, bool en,
                return ret;
 
        ret = hclge_bind_ring_with_vector(vport, vector_id, en, &ring_chain);
-       if (ret)
-               return ret;
 
        hclge_free_vector_ring_chain(&ring_chain);
 
-       return 0;
+       return ret;
 }
 
 static int hclge_set_vf_promisc_mode(struct hclge_vport *vport,