From: Sumit Semwal <sumit.semwal@linaro.org>
To: John Sheu <sheu@google.com>
Cc: linux-media@vger.kernel.org, John Sheu <sheu@chromium.org>
Subject: Re: [PATCH 3/3] dma-buf: restore args on failure of dma_buf_mmap
Date: Thu, 07 Feb 2013 15:54:52 +0530 [thread overview]
Message-ID: <511380F4.2070806@linaro.org> (raw)
In-Reply-To: <1360195382-32317-3-git-send-email-sheu@google.com>
Hi John,
On Thursday 07 February 2013 05:33 AM, John Sheu wrote:
> From: John Sheu <sheu@chromium.org>
>
> Callers to dma_buf_mmap expect to fput() the vma struct's vm_file
> themselves on failure. Not restoring the struct's data on failure
> causes a double-decrement of the vm_file's refcount.
Thanks for your patch; could you please re-send it to the correct,
relevant lists and me (as the maintainer of dma-buf) rather than just to
linux-media ml?
I just chanced to see this patch, otherwise it could easily have slipped
past me (and other interested parties).
You could run scripts/get_maintainer.pl on your patch to find out the
right lists / email IDs to CC.
Thanks and best regards,
~Sumit.
>
> Signed-off-by: John Sheu <sheu@google.com>
> ---
> drivers/base/dma-buf.c | 18 ++++++++++++++----
> 1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/base/dma-buf.c b/drivers/base/dma-buf.c
> index a3f79c4..01daf9c 100644
> --- a/drivers/base/dma-buf.c
> +++ b/drivers/base/dma-buf.c
> @@ -446,6 +446,9 @@ EXPORT_SYMBOL_GPL(dma_buf_kunmap);
> int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
> unsigned long pgoff)
> {
> + struct file *oldfile;
> + int ret;
> +
> if (WARN_ON(!dmabuf || !vma))
> return -EINVAL;
>
> @@ -459,14 +462,21 @@ int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
> return -EINVAL;
>
> /* readjust the vma */
> - if (vma->vm_file)
> - fput(vma->vm_file);
> -
> + oldfile = vma->vm_file;
> vma->vm_file = get_file(dmabuf->file);
>
> vma->vm_pgoff = pgoff;
>
> - return dmabuf->ops->mmap(dmabuf, vma);
> + ret = dmabuf->ops->mmap(dmabuf, vma);
> + if (ret) {
> + /* restore old parameters on failure */
> + vma->vm_file = oldfile;
> + fput(dmabuf->file);
> + } else {
> + if (oldfile)
> + fput(oldfile);
> + }
> + return ret;
> }
> EXPORT_SYMBOL_GPL(dma_buf_mmap);
>
>
next prev parent reply other threads:[~2013-02-07 10:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-07 0:03 [PATCH 1/3] [media] v4l2-mem2mem: use CAPTURE queue lock John Sheu
2013-02-07 0:03 ` [PATCH 2/3] [media]: v4l2-mem2mem: drop rdy_queue on STREAMOFF John Sheu
2013-02-28 15:45 ` Pawel Osciak
2013-02-07 0:03 ` [PATCH 3/3] dma-buf: restore args on failure of dma_buf_mmap John Sheu
2013-02-07 10:24 ` Sumit Semwal [this message]
2013-03-18 23:49 ` Mauro Carvalho Chehab
2013-03-25 11:24 ` Sumit Semwal
2013-02-28 15:44 ` [PATCH 1/3] [media] v4l2-mem2mem: use CAPTURE queue lock Pawel Osciak
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=511380F4.2070806@linaro.org \
--to=sumit.semwal@linaro.org \
--cc=linux-media@vger.kernel.org \
--cc=sheu@chromium.org \
--cc=sheu@google.com \
/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).