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 <rstoyanov@fedoraproject.org>
This commit is contained in:
Radostin Stoyanov 2026-03-14 14:01:26 +00:00
parent 16b252ee21
commit b8d118a758

View file

@ -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 */
}