net: fix coverity RESOURCE_LEAK

criu-3.12/criu/net.c:2043: overwrite_var: Overwriting "img" in "img =
open_image_at(-1, CR_FD_IP6TABLES, 0UL, pid)" leaks the storage that
"img" points to.

Signed-off-by: Adrian Reber <areber@redhat.com>
This commit is contained in:
Adrian Reber 2019-05-15 09:47:17 +00:00 committed by Andrei Vagin
parent eb732bcf0d
commit 8be1d457d7

View file

@ -2090,13 +2090,13 @@ static int restore_ip_dump(int type, int pid, char *cmd)
if (written < n) {
pr_perror("Failed to write to tmpfile "
"[written: %d; total: %d]", written, n);
return -1;
goto close;
}
}
if (fseek(tmp_file, 0, SEEK_SET)) {
pr_perror("Failed to set file position to beginning of tmpfile");
return -1;
goto close;
}
if (img) {
@ -2104,6 +2104,7 @@ static int restore_ip_dump(int type, int pid, char *cmd)
close_image(img);
}
close:
if(fclose(tmp_file)) {
pr_perror("Failed to close tmpfile");
}
@ -2208,6 +2209,7 @@ static inline int restore_iptables(int pid)
return -1;
if (empty_image(img)) {
ret = 0;
close_image(img);
goto ipt6;
}