[PATCH iproute2-next 3/7] devlink: fix memory leak in resource_ctx_fini

From: Tariq Toukan

Date: Tue Jun 09 2026 - 01:43:12 EST


From: Or Har-Toov <ohartoov@xxxxxxxxxx>

resource_ctx_init() allocates ctx->resources via resources_alloc()
which calls calloc(). resource_ctx_fini() calls resources_free() to
free the list items inside the struct, but never frees the struct
itself.

Signed-off-by: Or Har-Toov <ohartoov@xxxxxxxxxx>
Signed-off-by: Tariq Toukan <tariqt@xxxxxxxxxx>
---
devlink/devlink.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/devlink/devlink.c b/devlink/devlink.c
index 7a8be3ad9b6a..ba14c0056b1c 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -7441,6 +7441,7 @@ static int resource_ctx_init(struct resource_ctx *ctx, struct dl *dl)
static void resource_ctx_fini(struct resource_ctx *ctx)
{
resources_free(ctx->resources);
+ free(ctx->resources);
}

struct dpipe_ctx {
--
2.44.0