From: Sylwester Nawrocki <snjw23@gmail.com>
To: Tomasz Stanislawski <t.stanislaws@samsung.com>
Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
airlied@redhat.com, m.szyprowski@samsung.com,
kyungmin.park@samsung.com, laurent.pinchart@ideasonboard.com,
sumit.semwal@ti.com, daeinki@gmail.com, daniel.vetter@ffwll.ch,
robdclark@gmail.com, pawel@osciak.com,
linaro-mm-sig@lists.linaro.org, subashrp@gmail.com,
mchehab@redhat.com
Subject: Re: [PATCH 1/3] dma-buf: add vmap interface
Date: Tue, 10 Apr 2012 22:48:17 +0200 [thread overview]
Message-ID: <4F849C91.6090504@gmail.com> (raw)
In-Reply-To: <1334052691-5145-2-git-send-email-t.stanislaws@samsung.com>
Hi,
On 04/10/2012 12:11 PM, Tomasz Stanislawski wrote:
> From: Dave Airlie<airlied@redhat.com>
>
> Add vmap to dmabuf interface.
>
> Signed-off-by: Dave Airlie<airlied@redhat.com>
> ---
> drivers/base/dma-buf.c | 29 +++++++++++++++++++++++++++++
> include/linux/dma-buf.h | 16 ++++++++++++++++
> 2 files changed, 45 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/base/dma-buf.c b/drivers/base/dma-buf.c
> index 07cbbc6..3068258 100644
> --- a/drivers/base/dma-buf.c
> +++ b/drivers/base/dma-buf.c
> @@ -406,3 +406,32 @@ void dma_buf_kunmap(struct dma_buf *dmabuf, unsigned long page_num,
> dmabuf->ops->kunmap(dmabuf, page_num, vaddr);
> }
> EXPORT_SYMBOL_GPL(dma_buf_kunmap);
> +
> +/**
> + * dma_buf_vmap - Create virtual mapping for the buffer object into kernel address space. The same restrictions as for vmap and friends apply.
> + * @dma_buf: [in] buffer to vmap
> + *
> + * This call may fail due to lack of virtual mapping address space.
> + */
> +void *dma_buf_vmap(struct dma_buf *dmabuf)
> +{
> + WARN_ON(!dmabuf);
How about replacing this with:
if (WARN_ON(!dmabuf))
return NULL;
to avoid null pointer dereference right below ?
> + if (dmabuf->ops->vmap)
> + return dmabuf->ops->vmap(dmabuf);
> + return NULL;
> +}
> +EXPORT_SYMBOL(dma_buf_vmap);
> +
> +/**
> + * dma_buf_vunmap - Unmap a page obtained by dma_buf_vmap.
> + * @dma_buf: [in] buffer to vmap
> + */
> +void dma_buf_vunmap(struct dma_buf *dmabuf, void *vaddr)
> +{
> + WARN_ON(!dmabuf);
and here
if (WARN_ON(!dmabuf))
return;
?
> + if (dmabuf->ops->vunmap)
> + dmabuf->ops->vunmap(dmabuf, vaddr);
> +}
> +EXPORT_SYMBOL(dma_buf_vunmap);
--
Regards,
Sylwester
next prev parent reply other threads:[~2012-04-10 20:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-10 10:11 [PATCH 0/3] Integration of vb2-vmalloc and VIVI with dmabuf Tomasz Stanislawski
2012-04-10 10:11 ` [PATCH 1/3] dma-buf: add vmap interface Tomasz Stanislawski
2012-04-10 20:48 ` Sylwester Nawrocki [this message]
2012-04-10 10:11 ` [PATCH 2/3] v4l: vb2-vmalloc: add support for dmabuf importing Tomasz Stanislawski
2012-04-10 10:11 ` [PATCH 3/3] v4l: vivi: " Tomasz Stanislawski
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=4F849C91.6090504@gmail.com \
--to=snjw23@gmail.com \
--cc=airlied@redhat.com \
--cc=daeinki@gmail.com \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=kyungmin.park@samsung.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-media@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mchehab@redhat.com \
--cc=pawel@osciak.com \
--cc=robdclark@gmail.com \
--cc=subashrp@gmail.com \
--cc=sumit.semwal@ti.com \
--cc=t.stanislaws@samsung.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).