All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dma-buf: return -EINVAL if dmabuf object is NULL
@ 2021-08-18 11:58 Nuno Sá
  2021-08-18 12:09 ` Christian König
  0 siblings, 1 reply; 8+ messages in thread
From: Nuno Sá @ 2021-08-18 11:58 UTC (permalink / raw)
  To: linaro-mm-sig, dri-devel, linux-media
  Cc: Rob Clark, Christian König, Sumit Semwal

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);
 
-- 
2.32.0


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

end of thread, other threads:[~2021-08-18 17:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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.