[v2] vfio: fix mem leak when unmapping resource

Message ID 1599821862-27816-1-git-send-email-wangyunjian@huawei.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series [v2] vfio: fix mem leak when unmapping resource |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-testing success Testing PASS

Commit Message

Yunjian Wang Sept. 11, 2020, 10:57 a.m. UTC
From: Yunjian Wang <wangyunjian@huawei.com>

The 'vfio_res' is not freed when unmapping resource by primary process.
This leads to memory leak.

Fixes: ab53203e194b ("vfio: enable unmapping resource for secondary")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
v2:
   Update email address
---
 drivers/bus/pci/linux/pci_vfio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Burakov, Anatoly Sept. 17, 2020, 10:37 a.m. UTC | #1
On 11-Sep-20 11:57 AM, wangyunjian wrote:
> From: Yunjian Wang <wangyunjian@huawei.com>
> 
> The 'vfio_res' is not freed when unmapping resource by primary process.
> This leads to memory leak.
> 
> Fixes: ab53203e194b ("vfio: enable unmapping resource for secondary")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---

Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
  
David Marchand Oct. 5, 2020, 8:13 a.m. UTC | #2
On Fri, Sep 11, 2020 at 12:58 PM wangyunjian <wangyunjian@huawei.com> wrote:
>
> From: Yunjian Wang <wangyunjian@huawei.com>
>
> The 'vfio_res' is not freed when unmapping resource by primary process.
> This leads to memory leak.
>
> Fixes: ab53203e194b ("vfio: enable unmapping resource for secondary")
> Cc: stable@dpdk.org
>
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>

Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

Applied, thanks.
  

Patch

diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c
index c15ed3bad..91131ce6a 100644
--- a/drivers/bus/pci/linux/pci_vfio.c
+++ b/drivers/bus/pci/linux/pci_vfio.c
@@ -1003,7 +1003,7 @@  pci_vfio_unmap_resource_primary(struct rte_pci_device *dev)
 	}
 
 	TAILQ_REMOVE(vfio_res_list, vfio_res, next);
-
+	rte_free(vfio_res);
 	return 0;
 }