mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-18 00:58:31 +00:00
plugins/amdgpu: Close file on failures in amdgpu_plugin_dmabuf_restore
Close the file when either memory allocation or a file read fails in amdgpu_plugin_dmabuf_restore. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
This commit is contained in:
parent
79c347c1e2
commit
d96a2eb292
1 changed files with 3 additions and 2 deletions
|
|
@ -116,24 +116,25 @@ int amdgpu_plugin_dmabuf_restore(int id)
|
|||
buf = xmalloc(img_size);
|
||||
if (!buf) {
|
||||
pr_perror("Failed to allocate memory");
|
||||
fclose(img_fp);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
ret = read_fp(img_fp, buf, img_size);
|
||||
if (ret) {
|
||||
pr_perror("Unable to read from %s", path);
|
||||
fclose(img_fp);
|
||||
xfree(buf);
|
||||
return ret;
|
||||
}
|
||||
fclose(img_fp);
|
||||
|
||||
rd = criu_dmabuf_node__unpack(NULL, img_size, buf);
|
||||
if (rd == NULL) {
|
||||
pr_perror("Unable to parse the dmabuf message %d", id);
|
||||
xfree(buf);
|
||||
fclose(img_fp);
|
||||
return -1;
|
||||
}
|
||||
fclose(img_fp);
|
||||
|
||||
/* Match GEM handle with shared_dmabuf list */
|
||||
fd_id = amdgpu_id_for_handle(rd->gem_handle);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue