[CRIU] [PATCH] util: don't leak cr-img objects
Pavel Emelyanov
xemul at parallels.com
Thu Nov 19 04:14:39 PST 2015
On 11/18/2015 10:54 AM, Andrey Vagin wrote:
> From: Andrew Vagin <avagin at virtuozzo.com>
Some details would be nice. Where does it leak img?
> Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
> diff --git a/net.c b/net.c
> index bfdebad..45c8318 100644
> --- a/net.c
> +++ b/net.c
> @@ -726,16 +726,17 @@ err_free:
>
> static int restore_ip_dump(int type, int pid, char *cmd)
> {
> - int ret = -1;
> + int ret = 0;
> struct cr_img *img;
>
> img = open_image(type, O_RSTR, pid);
> - if (empty_image(img))
> - return 0;
> - if (img) {
> + if (img == NULL)
> + return -1;
There's no need in this check here, both close_image and empty_image
check fro it being null.
> +
> + if (!empty_image(img))
> ret = run_ip_tool(cmd, "restore", NULL, img_raw_fd(img), -1, 0);
> - close_image(img);
> - }
> +
> + close_image(img);
>
> return ret;
> }
>
More information about the CRIU
mailing list