diff --git a/mount.c b/mount.c index 562d6ca5c..20ae79b89 100644 --- a/mount.c +++ b/mount.c @@ -1250,8 +1250,12 @@ static int tmpfs_restore(struct mount_info *pm) close_image(img); img = open_image(CR_FD_TMPFS_IMG, O_RSTR, pm->mnt_id); } - if (!img || empty_image(img)) + if (!img) return -1; + if (empty_image(img)) { + close_image(img); + return -1; + } ret = cr_system(img_raw_fd(img), -1, -1, "tar", (char *[]) {"tar", "--extract", "--gzip", diff --git a/net.c b/net.c index d719471d9..51b31597a 100644 --- a/net.c +++ b/net.c @@ -729,8 +729,10 @@ static int restore_ip_dump(int type, int pid, char *cmd) struct cr_img *img; img = open_image(type, O_RSTR, pid); - if (empty_image(img)) + if (empty_image(img)) { + close_image(img); return 0; + } if (img) { ret = run_ip_tool(cmd, "restore", NULL, img_raw_fd(img), -1, 0); close_image(img);