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] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 17 Jul 2023 09:19:12 -0700
From:   Dave Jiang <dave.jiang@...el.com>
To:     Chenyuan Mi <michenyuan@...wei.com>, <dan.j.williams@...el.com>
CC:     <Jonathan.Cameron@...wei.com>, <rrichter@....com>,
        <alison.schofield@...el.com>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] cxl: Fix memory leak bug in alloc_mock_res()



On 7/16/23 21:16, Chenyuan Mi wrote:
> When gen_pool_alloc_algo() fails, the error handling path
> forgets to free 'res'. It would cause a memory leak bug.
> 
> Fix it by add kfree() in error handling path.
> 
> Signed-off-by: Chenyuan Mi <michenyuan@...wei.com>
Reviewed-by: Dave Jiang <dave.jiang@...el.com>

> ---
>   tools/testing/cxl/test/cxl.c |   4 +++-
>   1 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/cxl/test/cxl.c b/tools/testing/cxl/test/cxl.c
> index 0e78d8e19895..250ffd147067 100644
> --- a/tools/testing/cxl/test/cxl.c
> +++ b/tools/testing/cxl/test/cxl.c
> @@ -405,8 +405,10 @@ static struct cxl_mock_res *alloc_mock_res(resource_size_t size, int align)
>   	INIT_LIST_HEAD(&res->list);
>   	phys = gen_pool_alloc_algo(cxl_mock_pool, size,
>   				   gen_pool_first_fit_align, &data);
> -	if (!phys)
> +	if (!phys) {
> +		kfree(res);
>   		return NULL;
> +	}
>   
>   	res->range = (struct range) {
>   		.start = phys,

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ