patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [DPDK] examples/vhost: fix memory leak on forwarding packets.
@ 2021-08-17 17:04 Wenwu Ma
  0 siblings, 0 replies; only message in thread
From: Wenwu Ma @ 2021-08-17 17:04 UTC (permalink / raw)
  To: build_sh; +Cc: Wenwu Ma, stable

In function virtio_tx_local(), when the device receiving the packet
is the same as the device to which the packet is forwarded,
or the device is removed, we return but not free the packet,
it will cause a memory leak.

Fixes: 4796ad63ba1f ("examples/vhost: import userspace vhost application")
Cc: stable@dpdk.org

Signed-off-by: Wenwu Ma <wenwux.ma@intel.com>
---
 examples/vhost/main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index bc3d71c898..07fd90ec64 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -965,6 +965,7 @@ virtio_tx_local(struct vhost_dev *vdev, struct rte_mbuf *m)
 		return -1;
 
 	if (vdev->vid == dst_vdev->vid) {
+		rte_pktmbuf_free(m);
 		RTE_LOG_DP(DEBUG, VHOST_DATA,
 			"(%d) TX: src and dst MAC is same. Dropping packet.\n",
 			vdev->vid);
@@ -975,6 +976,7 @@ virtio_tx_local(struct vhost_dev *vdev, struct rte_mbuf *m)
 		"(%d) TX: MAC address is local\n", dst_vdev->vid);
 
 	if (unlikely(dst_vdev->remove)) {
+		rte_pktmbuf_free(m);
 		RTE_LOG_DP(DEBUG, VHOST_DATA,
 			"(%d) device is marked for removal\n", dst_vdev->vid);
 		return 0;
-- 
2.25.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-17  5:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-17 17:04 [dpdk-stable] [DPDK] examples/vhost: fix memory leak on forwarding packets Wenwu Ma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).