]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
devlink: fix memory leak in resource_ctx_fini
authorOr Har-Toov <ohartoov@nvidia.com>
Tue, 9 Jun 2026 05:39:49 +0000 (08:39 +0300)
committerDavid Ahern <dsahern@kernel.org>
Sun, 28 Jun 2026 17:12:40 +0000 (11:12 -0600)
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@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
devlink/devlink.c

index 7a8be3ad9b6aab01f28ddd2ea47cd7d35aa24c29..ba14c0056b1cb5b2f4f906a10242b96c4cb00c59 100644 (file)
@@ -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 {