linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: John Hubbard <jhubbard@nvidia.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Matt Porter <mporter@kernel.crashing.org>,
	Alexandre Bounine <alex.bou9@gmail.com>,
	Sumit Semwal <sumit.semwal@linaro.org>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	<linux-media@vger.kernel.org>, <stable@vger.kernel.org>
Subject: Re: [PATCH 1/2] rapidio: fix an error in get_user_pages_fast() error handling
Date: Mon, 18 May 2020 14:37:23 -0700	[thread overview]
Message-ID: <20200518143723.2c3159ddd53345b9cde5d869@linux-foundation.org> (raw)
In-Reply-To: <20200517235620.205225-2-jhubbard@nvidia.com>

On Sun, 17 May 2020 16:56:19 -0700 John Hubbard <jhubbard@nvidia.com> wrote:

> In the case of get_user_pages_fast() returning fewer pages than
> requested, rio_dma_transfer() does not quite do the right thing.
> It attempts to release all the pages that were requested, rather
> than just the pages that were pinned.
> 
> Fix the error handling so that only the pages that were successfully
> pinned are released.
> 
> ...
>
> --- a/drivers/rapidio/devices/rio_mport_cdev.c
> +++ b/drivers/rapidio/devices/rio_mport_cdev.c
> @@ -877,6 +877,11 @@ rio_dma_transfer(struct file *filp, u32 transfer_mode,
>  				rmcd_error("pinned %ld out of %ld pages",
>  					   pinned, nr_pages);
>  			ret = -EFAULT;
> +			/*
> +			 * Set nr_pages up to mean "how many pages to unpin, in
> +			 * the error handler:
> +			 */
> +			nr_pages = pinned;
>  			goto err_pg;
>  		}

The code is a bit odd.  If (xfer->loc_addr == 0) then we do the `else'
stuff then fall through to

err_pg:
	if (!req->page_list) {
		for (i = 0; i < nr_pages; i++)
			put_page(page_list[i]);
		kfree(page_list);
	}

all of which is a big no-op because nr_pages==0 and page_list==NULL,
but it could all be easily avoided.

Oh well.  Reviewed-by:me.

  reply	other threads:[~2020-05-18 21:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-17 23:56 [PATCH 0/2] rapidio: convert to pin_user_pages(), plus a small fix John Hubbard
2020-05-17 23:56 ` [PATCH 1/2] rapidio: fix an error in get_user_pages_fast() error handling John Hubbard
2020-05-18 21:37   ` Andrew Morton [this message]
2020-05-17 23:56 ` [PATCH 2/2] rapidio: convert get_user_pages() --> pin_user_pages() John Hubbard

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=20200518143723.2c3159ddd53345b9cde5d869@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=alex.bou9@gmail.com \
    --cc=dan.carpenter@oracle.com \
    --cc=jhubbard@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mporter@kernel.crashing.org \
    --cc=stable@vger.kernel.org \
    --cc=sumit.semwal@linaro.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).