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: <20241019151045.5b86cb3e@jic23-huawei>
Date: Sat, 19 Oct 2024 15:10:45 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: Jinjie Ruan <ruanjinjie@...wei.com>
Cc: <mazziesaccount@...il.com>, <lars@...afoo.de>,
 <linux-iio@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] iio: gts-helper: Fix memory leaks for the error path
 of iio_gts_build_avail_scale_table()

On Wed, 16 Oct 2024 09:24:53 +0800
Jinjie Ruan <ruanjinjie@...wei.com> wrote:

> If per_time_scales[i] or per_time_gains[i] kcalloc fails in the for loop
> of iio_gts_build_avail_scale_table(), the err_free_out will fail to call
> kfree() each time when i is reduced to 0, so all the per_time_scales[0]
> and per_time_gains[0] will not be freed, which will cause memory leaks.
> 
> Fix it by checking if i >= 0.
> 
> Cc: stable@...r.kernel.org
> Fixes: 38416c28e168 ("iio: light: Add gain-time-scale helpers")
> Reviewed-by: Matti Vaittinen <mazziesaccount@...il.com>
> Signed-off-by: Jinjie Ruan <ruanjinjie@...wei.com>
Applied.
> ---
> v2:
> - Update the commit message.
> - Add Reviewed-by.
> ---
>  drivers/iio/industrialio-gts-helper.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/industrialio-gts-helper.c b/drivers/iio/industrialio-gts-helper.c
> index 7326c7949244..5f131bc1a01e 100644
> --- a/drivers/iio/industrialio-gts-helper.c
> +++ b/drivers/iio/industrialio-gts-helper.c
> @@ -315,7 +315,7 @@ static int iio_gts_build_avail_scale_table(struct iio_gts *gts)
>  	return 0;
>  
>  err_free_out:
> -	for (i--; i; i--) {
> +	for (i--; i >= 0; i--) {
>  		kfree(per_time_scales[i]);
>  		kfree(per_time_gains[i]);
>  	}


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ