All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dma-buf: call kfree() w/o mutex held in dma_buf_attach()
@ 2019-04-25 15:48 Emil Velikov
  2019-04-25 15:57 ` Daniel Vetter
  0 siblings, 1 reply; 2+ messages in thread
From: Emil Velikov @ 2019-04-25 15:48 UTC (permalink / raw)
  To: dri-devel; +Cc: emil.l.velikov

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>
---
 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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-04-25 15:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.