[CRIU] [PATCH v2] page-read: fix open_page_read usage

Mike Rapoport rppt at linux.vnet.ibm.com
Wed Jun 29 00:41:23 PDT 2016


On Tue, Jun 28, 2016 at 06:48:55PM +0300, Pavel Tikhomirov wrote:
> 1. Fix uninitialized use of pr in cr_dedup_one_pagemap and get_page:
> https://github.com/xemul/criu/issues/178
> 2. In ud_open, close pr in case of error returned from find_vmas->
> collect_uffd_pages as we free lpi with lpi->pr open; so need check in
> lpi_fini if uffd is >0 before close
> 
> v2:rebase to new criu-dev
> Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>

Acked-by: Mike Rapoport <rppt at linux.vnet.ibm.com>

> ---
>  criu/cr-dedup.c | 6 ++----
>  criu/uffd.c     | 4 ++--
>  2 files changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/criu/cr-dedup.c b/criu/cr-dedup.c
> index 538f650..ca5a930 100644
> --- a/criu/cr-dedup.c
> +++ b/criu/cr-dedup.c
> @@ -66,10 +66,8 @@ static int cr_dedup_one_pagemap(int pid)
>  	struct iovec iov;
> 
>  	ret = open_page_read(pid, &pr, PR_TASK | PR_MOD);
> -	if (ret <= 0) {
> -		ret = -1;
> -		goto exit;
> -	}
> +	if (ret <= 0)
> +		return -1;
> 
>  	prp = pr.parent;
>  	if (!prp)
> diff --git a/criu/uffd.c b/criu/uffd.c
> index 1e0a57a..6c9b141 100644
> --- a/criu/uffd.c
> +++ b/criu/uffd.c
> @@ -76,7 +76,7 @@ static struct lazy_pages_info *lpi_init(void)
> 
>  static void lpi_fini(struct lazy_pages_info *lpi)
>  {
> -	if (lpi->uffd)
> +	if (lpi->uffd > 0)
>  		close(lpi->uffd);
>  	if (lpi->pr.close)
>  		lpi->pr.close(&lpi->pr);
> @@ -323,7 +323,7 @@ static struct lazy_pages_info *ud_open(int listen, struct sockaddr_un *saddr)
>  	return lpi;
> 
>  out:
> -	free(lpi);
> +	lpi_fini(lpi);
>  	close_safe(&client);
>  	return NULL;
>  }
> -- 
> 2.5.5
> 



More information about the CRIU mailing list