summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'net-libs/xdp-tools/files/1.4.1-fix-memory-leak-in-xsk_setup_xdp_prog.patch')
-rw-r--r--net-libs/xdp-tools/files/1.4.1-fix-memory-leak-in-xsk_setup_xdp_prog.patch34
1 files changed, 34 insertions, 0 deletions
diff --git a/net-libs/xdp-tools/files/1.4.1-fix-memory-leak-in-xsk_setup_xdp_prog.patch b/net-libs/xdp-tools/files/1.4.1-fix-memory-leak-in-xsk_setup_xdp_prog.patch
new file mode 100644
index 000000000000..6c95a970f876
--- /dev/null
+++ b/net-libs/xdp-tools/files/1.4.1-fix-memory-leak-in-xsk_setup_xdp_prog.patch
@@ -0,0 +1,34 @@
+
+Patch from:
+https://github.com/xdp-project/xdp-tools/commit/cae9c91353cd3ed51753168203ed101905b9ac9e
+
+From cae9c91353cd3ed51753168203ed101905b9ac9e Mon Sep 17 00:00:00 2001
+From: Ric Li <ming3.li@intel.com>
+Date: Tue, 21 Nov 2023 15:36:57 +0800
+Subject: [PATCH] libxdp: Fix xdp prog memory leak in xsk_setup_xdp_prog
+
+In the xsk_setup_xdp_prog function, the xsk structure
+temporarily takes ownership of an xdp_prog and stores it in
+ctx->xdp_prog. However, the allocated memory is not freed
+in xsk_destroy_xsk_struct, leading to a memory leak. This
+commit addresses the issue by adding a call to
+xdp_program_close to properly release the allocated
+xdp_prog memory.
+
+Signed-off-by: Ric Li <ming3.li@intel.com>
+---
+ lib/libxdp/xsk.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/lib/libxdp/xsk.c b/lib/libxdp/xsk.c
+index a854f771..b3527fb6 100644
+--- a/lib/libxdp/xsk.c
++++ b/lib/libxdp/xsk.c
+@@ -978,6 +978,7 @@ static struct xsk_ctx *xsk_create_ctx(struct xsk_socket *xsk,
+
+ static void xsk_destroy_xsk_struct(struct xsk_socket *xsk)
+ {
++ xdp_program__close(xsk->ctx->xdp_prog);
+ free(xsk->ctx);
+ free(xsk);
+ }