From: Daniel Vetter <daniel@ffwll.ch>
To: Emil Velikov <emil.l.velikov@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] dma-buf: call kfree() w/o mutex held in dma_buf_attach()
Date: Thu, 25 Apr 2019 17:57:52 +0200 [thread overview]
Message-ID: <20190425155752.GC3273@phenom.ffwll.local> (raw)
In-Reply-To: <20190425154850.32740-1-emil.l.velikov@gmail.com>
On Thu, Apr 25, 2019 at 04:48:50PM +0100, Emil Velikov wrote:
> From: Emil Velikov <emil.velikov@collabora.com>
>
> In dma_buf_attach() we allocate memory w/o a mutex being held, thus in
> the error path we should kfree() it after the mutex_unlock.
>
> The inverse function dma_buf_deattach() gets this right.
>
> Cc: Sumit Semwal <sumit.semwal@linaro.org>
> Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
I don't think this matters, but +1 on ocd.
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
> drivers/dma-buf/dma-buf.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> index 3ae6c0c2cc02..57ddeb735b8b 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -579,8 +579,8 @@ struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf,
> return attach;
>
> err_attach:
> - kfree(attach);
> mutex_unlock(&dmabuf->lock);
> + kfree(attach);
> return ERR_PTR(ret);
> }
> EXPORT_SYMBOL_GPL(dma_buf_attach);
> --
> 2.21.0
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
prev parent reply other threads:[~2019-04-25 15:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-25 15:48 [PATCH] dma-buf: call kfree() w/o mutex held in dma_buf_attach() Emil Velikov
2019-04-25 15:57 ` Daniel Vetter [this message]
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=20190425155752.GC3273@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=emil.l.velikov@gmail.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