Skip to contentSkip to conversation

vfio: fix mem leak when unmapping resource

PATCH New Yunjian Wang 4 participants 4 messages Jun 14, 2020 – Oct 5, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vfio: fix mem leak when unmapping resource

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")
---
 drivers/bus/pci/linux/pci_vfio.c | 1 +
 1 file changed, 1 insertion(+)
drivers/bus/pci/linux/pci_vfio.c +1 -0
index 64cd84a68..bf4c3c1fa 100644
@@ -966,6 +966,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;
 }
Signature · 1 line
2.18.1
#1 lore raw

PATCH v2 1/1 vfio: fix mem leak when unmapping resource

From: Yunjian Wang <[email protected]>

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")

---
v2:
Update email address

---
 drivers/bus/pci/linux/pci_vfio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/pci/linux/pci_vfio.c +1 -1
index c15ed3bad..91131ce6a 100644
@@ -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;
 }
 
Signature · 1 line
2.23.0
Acked-by Anatoly Burakov on v2 1/1 Applied
#3 lore raw
In reply to wangyunjian
Quoted 10 lines · wangyunjian

From: Yunjian Wang <[email protected]>

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")

Applied, thanks.

Signature · 1 line
David Marchand