dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: "Nuno Sá" <nuno.sa@analog.com>,
	linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org,
	linux-media@vger.kernel.org
Cc: Rob Clark <rob@ti.com>, Sumit Semwal <sumit.semwal@linaro.org>
Subject: Re: [PATCH] dma-buf: return -EINVAL if dmabuf object is NULL
Date: Wed, 18 Aug 2021 14:09:56 +0200	[thread overview]
Message-ID: <9a63b45f-6fec-6269-ae16-8604b08514de@amd.com> (raw)
In-Reply-To: <20210818115810.274084-1-nuno.sa@analog.com>

To be honest I think the if(WARN_ON(!dmabuf)) return -EINVAL handling 
here is misleading in the first place.

Returning -EINVAL on a hard coding error is not good practice and should 
probably be removed from the DMA-buf subsystem in general.

Christian.

Am 18.08.21 um 13:58 schrieb Nuno Sá:
> On top of warning about a NULL object, we also want to return with a
> proper error code (as done in 'dma_buf_begin_cpu_access()'). Otherwise,
> we will get a NULL pointer dereference.
>
> Fixes: fc13020e086b ("dma-buf: add support for kernel cpu access")
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> ---
>   drivers/dma-buf/dma-buf.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> index 63d32261b63f..8ec7876dd523 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -1231,7 +1231,8 @@ int dma_buf_end_cpu_access(struct dma_buf *dmabuf,
>   {
>   	int ret = 0;
>   
> -	WARN_ON(!dmabuf);
> +	if (WARN_ON(!dmabuf))
> +		return -EINVAL;
>   
>   	might_lock(&dmabuf->resv->lock.base);
>   


  reply	other threads:[~2021-08-18 12:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-18 11:58 [PATCH] dma-buf: return -EINVAL if dmabuf object is NULL Nuno Sá
2021-08-18 12:09 ` Christian König [this message]
2021-08-18 12:17   ` Sa, Nuno
2021-08-18 12:31     ` Christian König
2021-08-18 12:46       ` [Linaro-mm-sig] " Daniel Vetter
2021-08-18 12:57         ` Christian König
2021-08-18 13:13           ` Sa, Nuno
2021-08-18 13:28             ` Christian König

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=9a63b45f-6fec-6269-ae16-8604b08514de@amd.com \
    --to=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-media@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=rob@ti.com \
    --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