Commit 8dd32ad0 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

image: Fixup error paths in check_img_inventory

 - Free unpacked PB data
 - Close file descriptor
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent a4f4ca73
...@@ -22,37 +22,37 @@ TaskKobjIdsEntry *root_ids; ...@@ -22,37 +22,37 @@ TaskKobjIdsEntry *root_ids;
int check_img_inventory(void) int check_img_inventory(void)
{ {
int fd, ret; int fd, ret = -1;
InventoryEntry *he; InventoryEntry *he;
fd = open_image_ro(CR_FD_INVENTORY); fd = open_image_ro(CR_FD_INVENTORY);
if (fd < 0) if (fd < 0)
return -1; return -1;
ret = pb_read_one(fd, &he, PB_INVENTORY); if (pb_read_one(fd, &he, PB_INVENTORY) < 0)
close(fd); goto out_close;
if (ret < 0)
return ret;
fdinfo_per_id = he->has_fdinfo_per_id ? he->fdinfo_per_id : false; fdinfo_per_id = he->has_fdinfo_per_id ? he->fdinfo_per_id : false;
ret = he->img_version;
if (he->root_ids) { if (he->root_ids) {
root_ids = xmalloc(sizeof(*root_ids)); root_ids = xmalloc(sizeof(*root_ids));
if (!root_ids) if (!root_ids)
return -1; goto out_err;
memcpy(root_ids, he->root_ids, sizeof(*root_ids)); memcpy(root_ids, he->root_ids, sizeof(*root_ids));
inventory_entry__free_unpacked(he, NULL);
} }
if (ret != CRTOOLS_IMAGES_V1) { if (he->img_version != CRTOOLS_IMAGES_V1) {
pr_err("Not supported images version %u\n", ret); pr_err("Not supported images version %u\n", he->img_version);
return -1; goto out_err;
} }
ret = 0;
return 0; out_err:
inventory_entry__free_unpacked(he, NULL);
out_close:
close(fd);
return ret;
} }
int write_img_inventory(void) int write_img_inventory(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment