lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <a6e64fe8-8b27-2ffa-fde4-3e3d26ea4049@amd.com>
Date: Thu, 29 Jan 2026 08:41:55 -0800
From: Lizhi Hou <lizhi.hou@....com>
To: zishun yi <zishun.yi.dev@...il.com>, Min Ma <mamin506@...il.com>, Oded
 Gabbay <ogabbay@...nel.org>
CC: <dri-devel@...ts.freedesktop.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] accel/amdxdna: Fix memory leak in amdxdna_ubuf_map

Thanks for fixing this. Could you add 'Fixes' tag?

Lizhi

On 1/29/26 02:07, zishun yi wrote:
> From: Zishun Yi <zishun.yi.dev@...il.com>
>
> The amdxdna_ubuf_map() function allocates memory for sg and
> internal sg table structures, but it fails to free them if subsequent
> operations (sg_alloc_table_from_pages or dma_map_sgtable) fail.
>
> Signed-off-by: Zishun Yi <zishun.yi.dev@...il.com>
> ---
>   drivers/accel/amdxdna/amdxdna_ubuf.c | 10 ++++++++--
>   1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/accel/amdxdna/amdxdna_ubuf.c b/drivers/accel/amdxdna/amdxdna_ubuf.c
> index 077b2261cf2a..9e3b3b055caa 100644
> --- a/drivers/accel/amdxdna/amdxdna_ubuf.c
> +++ b/drivers/accel/amdxdna/amdxdna_ubuf.c
> @@ -34,15 +34,21 @@ static struct sg_table *amdxdna_ubuf_map(struct dma_buf_attachment *attach,
>   	ret = sg_alloc_table_from_pages(sg, ubuf->pages, ubuf->nr_pages, 0,
>   					ubuf->nr_pages << PAGE_SHIFT, GFP_KERNEL);
>   	if (ret)
> -		return ERR_PTR(ret);
> +		goto err_free_sg;
>   
>   	if (ubuf->flags & AMDXDNA_UBUF_FLAG_MAP_DMA) {
>   		ret = dma_map_sgtable(attach->dev, sg, direction, 0);
>   		if (ret)
> -			return ERR_PTR(ret);
> +			goto err_free_table;
>   	}
>   
>   	return sg;
> +
> +err_free_table:
> +	sg_free_table(sg);
> +err_free_sg:
> +	kfree(sg);
> +	return ERR_PTR(ret);
>   }
>   
>   static void amdxdna_ubuf_unmap(struct dma_buf_attachment *attach,

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ