xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@epam.com>
To: Jan Beulich <jbeulich@suse.com>, Juergen Gross <jgross@suse.com>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH] xen-front-pgdir-shbuf: don't record wrong grant handle upon error
Date: Tue, 23 Feb 2021 18:28:13 +0000	[thread overview]
Message-ID: <75c64c79-7458-19ca-1346-4c0e090cf0f7@epam.com> (raw)
In-Reply-To: <82414b0f-1b63-5509-7c1d-5bcc8239a3de@suse.com>

Hello, Jan!

On 2/23/21 6:26 PM, Jan Beulich wrote:
> In order for subsequent unmapping to not mistakenly unmap handle 0,
> record a perceived always-invalid one instead.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> Reviewed-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
> ---
> v2: Use INVALID_GRANT_HANDLE.
>
> --- a/drivers/xen/xen-front-pgdir-shbuf.c
> +++ b/drivers/xen/xen-front-pgdir-shbuf.c
> @@ -305,11 +305,18 @@ static int backend_map(struct xen_front_
>   
>   	/* Save handles even if error, so we can unmap. */
>   	for (cur_page = 0; cur_page < buf->num_pages; cur_page++) {
> -		buf->backend_map_handles[cur_page] = map_ops[cur_page].handle;
> -		if (unlikely(map_ops[cur_page].status != GNTST_okay))
> +		if (likely(map_ops[cur_page].status == GNTST_okay)) {
> +			buf->backend_map_handles[cur_page] =
> +				map_ops[cur_page].handle;
> +		} else {
> +			buf->backend_map_handles[cur_page] =
> +				INVALID_GRANT_HANDLE;
> +			if (!ret)
> +				ret = -ENXIO;
>   			dev_err(&buf->xb_dev->dev,
>   				"Failed to map page %d: %d\n",
>   				cur_page, map_ops[cur_page].status);
> +		}
>   	}
>   
>   	if (ret) {

  reply	other threads:[~2021-02-23 18:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-23 16:26 [PATCH] xen-front-pgdir-shbuf: don't record wrong grant handle upon error Jan Beulich
2021-02-23 18:28 ` Oleksandr Andrushchenko [this message]
2021-02-24  0:31   ` Boris Ostrovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=75c64c79-7458-19ca-1346-4c0e090cf0f7@epam.com \
    --to=oleksandr_andrushchenko@epam.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=jbeulich@suse.com \
    --cc=jgross@suse.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).