mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH V1] accel/amdxdna: Reject a zero sized buffer in amdxdna_gem_prime_import()
@ 2026-11-20  2:35 Lizhi Hou
  2026-11-20 12:32 ` Christian König
  0 siblings, 1 reply; 2+ messages in thread
From: Lizhi Hou @ 2026-11-20  2:35 UTC (permalink / raw)
  To: ogabbay, quic_jhugo, dri-devel, mario.limonciello,
	karol.wachowski, max.zhen, christian.koenig, linaro-mm-sig
  Cc: Lizhi Hou, linux-kernel, sonal.santan

Zero sized buffer is not supported. Check the buffer size and return
-EINVAL if the size is zero.

Fixes: e486147c912f ("accel/amdxdna: Add BO import and export")
Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
---
 drivers/accel/amdxdna/amdxdna_gem.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/accel/amdxdna/amdxdna_gem.c b/drivers/accel/amdxdna/amdxdna_gem.c
index ffe12a722dfe..4d7f3de88cd3 100644
--- a/drivers/accel/amdxdna/amdxdna_gem.c
+++ b/drivers/accel/amdxdna/amdxdna_gem.c
@@ -1133,6 +1133,9 @@ amdxdna_gem_prime_import(struct drm_device *dev, struct dma_buf *dma_buf)
 	struct sg_table *sgt;
 	int ret;
 
+	if (!dma_buf->size)
+		return ERR_PTR(-EINVAL);
+
 	get_dma_buf(dma_buf);
 
 	attach = dma_buf_attach(dma_buf, dev->dev);
-- 
2.34.1


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

* Re: [PATCH V1] accel/amdxdna: Reject a zero sized buffer in amdxdna_gem_prime_import()
  2026-11-20  2:35 [PATCH V1] accel/amdxdna: Reject a zero sized buffer in amdxdna_gem_prime_import() Lizhi Hou
@ 2026-11-20 12:32 ` Christian König
  0 siblings, 0 replies; 2+ messages in thread
From: Christian König @ 2026-11-20 12:32 UTC (permalink / raw)
  To: Lizhi Hou, ogabbay, quic_jhugo, dri-devel, mario.limonciello,
	karol.wachowski, max.zhen, linaro-mm-sig
  Cc: linux-kernel, sonal.santan

On 11/20/26 03:35, Lizhi Hou wrote:
> Zero sized buffer is not supported. Check the buffer size and return
> -EINVAL if the size is zero.

Oh that is surprising a zero sized buffer shouldn't be supported by DMA-buf in the first place.

Doesn't DMA-buf check that somewhere?

Regards,
Christian.

> 
> Fixes: e486147c912f ("accel/amdxdna: Add BO import and export")
> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
> ---
>  drivers/accel/amdxdna/amdxdna_gem.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/accel/amdxdna/amdxdna_gem.c b/drivers/accel/amdxdna/amdxdna_gem.c
> index ffe12a722dfe..4d7f3de88cd3 100644
> --- a/drivers/accel/amdxdna/amdxdna_gem.c
> +++ b/drivers/accel/amdxdna/amdxdna_gem.c
> @@ -1133,6 +1133,9 @@ amdxdna_gem_prime_import(struct drm_device *dev, struct dma_buf *dma_buf)
>  	struct sg_table *sgt;
>  	int ret;
>  
> +	if (!dma_buf->size)
> +		return ERR_PTR(-EINVAL);
> +
>  	get_dma_buf(dma_buf);
>  
>  	attach = dma_buf_attach(dma_buf, dev->dev);


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

end of thread, other threads:[~2026-11-20 12:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-20  2:35 [PATCH V1] accel/amdxdna: Reject a zero sized buffer in amdxdna_gem_prime_import() Lizhi Hou
2026-11-20 12:32 ` Christian König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®