From b8d118a758a6d07427cd1e4e65ea44c00cb8b5ec Mon Sep 17 00:00:00 2001 From: Radostin Stoyanov Date: Sat, 14 Mar 2026 14:01:26 +0000 Subject: [PATCH] plugin/amdgpu: fix memory leak in dmabuf restore error paths Free the protobuf message and buffer when returning early from amdgpu_plugin_dmabuf_restore() on failure to find a dmabuf fd. Signed-off-by: Radostin Stoyanov --- plugins/amdgpu/amdgpu_plugin_dmabuf.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/amdgpu/amdgpu_plugin_dmabuf.c b/plugins/amdgpu/amdgpu_plugin_dmabuf.c index d4be9ad53..e76628cc2 100644 --- a/plugins/amdgpu/amdgpu_plugin_dmabuf.c +++ b/plugins/amdgpu/amdgpu_plugin_dmabuf.c @@ -139,12 +139,16 @@ int amdgpu_plugin_dmabuf_restore(int id) fd_id = amdgpu_id_for_handle(rd->gem_handle); if (fd_id == -1) { pr_err("Failed to find dmabuf_fd for GEM handle = %d\n", rd->gem_handle); + criu_dmabuf_node__free_unpacked(rd, NULL); + xfree(buf); return 1; } int dmabuf_fd = fdstore_get(fd_id); if (dmabuf_fd == -1) { pr_err("Failed to find dmabuf_fd for GEM handle = %d\n", rd->gem_handle); + criu_dmabuf_node__free_unpacked(rd, NULL); + xfree(buf); return 1; /* Retry needed */ }