Commit 49448676 authored by Andrew Vagin's avatar Andrew Vagin Committed by Pavel Emelyanov

util: don't leak cr-img objects (v2)

We need to call close_image() for "empty" images.

v2: don't touch generic functiuons
Signed-off-by: 's avatarAndrew Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 490021ef
...@@ -1250,8 +1250,12 @@ static int tmpfs_restore(struct mount_info *pm) ...@@ -1250,8 +1250,12 @@ static int tmpfs_restore(struct mount_info *pm)
close_image(img); close_image(img);
img = open_image(CR_FD_TMPFS_IMG, O_RSTR, pm->mnt_id); img = open_image(CR_FD_TMPFS_IMG, O_RSTR, pm->mnt_id);
} }
if (!img || empty_image(img)) if (!img)
return -1; return -1;
if (empty_image(img)) {
close_image(img);
return -1;
}
ret = cr_system(img_raw_fd(img), -1, -1, "tar", ret = cr_system(img_raw_fd(img), -1, -1, "tar",
(char *[]) {"tar", "--extract", "--gzip", (char *[]) {"tar", "--extract", "--gzip",
......
...@@ -729,8 +729,10 @@ static int restore_ip_dump(int type, int pid, char *cmd) ...@@ -729,8 +729,10 @@ static int restore_ip_dump(int type, int pid, char *cmd)
struct cr_img *img; struct cr_img *img;
img = open_image(type, O_RSTR, pid); img = open_image(type, O_RSTR, pid);
if (empty_image(img)) if (empty_image(img)) {
close_image(img);
return 0; return 0;
}
if (img) { if (img) {
ret = run_ip_tool(cmd, "restore", NULL, img_raw_fd(img), -1, 0); ret = run_ip_tool(cmd, "restore", NULL, img_raw_fd(img), -1, 0);
close_image(img); close_image(img);
......
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