[CRIU] [PATCH] shmem: handle errors of img_raw_fd()

Pavel Emelyanov xemul at parallels.com
Tue May 5 03:43:01 PDT 2015


On 05/01/2015 04:25 PM, Andrey Vagin wrote:
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
>  shmem.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/shmem.c b/shmem.c
> index b2900f4..17a0153 100644
> --- a/shmem.c
> +++ b/shmem.c
> @@ -156,6 +156,11 @@ static int restore_shmem_content(void *addr, struct shmem_info *si)
>  		return -1;
>  
>  	fd_pg = img_raw_fd(pr.pi);
> +	if (fd_pg < 0) {

This should be BUG_ON() as image here cannot be lazy (O_CREAT check in
open_image_at).

> +		ret = -1;
> +		goto err;
> +	}
> +
>  	while (1) {
>  		unsigned long vaddr;
>  		unsigned nr_pages;
> @@ -190,6 +195,7 @@ static int restore_shmem_content(void *addr, struct shmem_info *si)
>  			pr.put_pagemap(&pr);
>  	}
>  
> +err:
>  	pr.close(&pr);
>  	return ret;
>  }
> 



More information about the CRIU mailing list