summaryrefslogtreecommitdiff
blob: 6c95a970f876c3c11f5e0abb98248b6566908144 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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);
 }