mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Zicheng Qu <quzicheng@huawei.com>,
	jic23@kernel.org, lars@metafoo.de, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: tanghui20@huawei.com, zhangqiao22@huawei.com, judy.chenhui@huawei.com
Subject: Re: [PATCH] iio: fix memory leak for iio_gts_build_avail_scale_table()
Date: Thu, 31 Oct 2024 09:32:11 +0200	[thread overview]
Message-ID: <9ee46109-8503-4b5d-bfd4-45b7ac03029a@gmail.com> (raw)
In-Reply-To: <20241031014743.2313121-1-quzicheng@huawei.com>

Hi Zicheng

On 31/10/2024 03:47, Zicheng Qu wrote:
> In iio_gts_build_avail_scale_table(), the memory allocated for
> per_time_gains is freed using kfree(per_time_gains) before return 0.
> However, the type per_time_gains is 'int **', and the memory allocated
> for its inner elements is not being freed, leading to a memory leak.
> 
> Cc: stable@vger.kernel.org # v6.6+
> Fixes: 38416c28e168 ("iio: light: Add gain-time-scale helpers")
> Signed-off-by: Zicheng Qu <quzicheng@huawei.com>
> ---
>   drivers/iio/industrialio-gts-helper.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/iio/industrialio-gts-helper.c b/drivers/iio/industrialio-gts-helper.c
> index 59d7615c0f56..f2450b2e740d 100644
> --- a/drivers/iio/industrialio-gts-helper.c
> +++ b/drivers/iio/industrialio-gts-helper.c
> @@ -307,6 +307,8 @@ static int iio_gts_build_avail_scale_table(struct iio_gts *gts)
>   	if (ret)
>   		goto err_free_out;
>   
> +	for (j = 0; j < gts->num_itime; j++)
> +		kfree(per_time_gains[i]);
>   	kfree(per_time_gains);
>   	gts->per_time_avail_scale_tables = per_time_scales;
>   

You're right, thanks!
This, however, was already fixed by:
https://lore.kernel.org/all/20241011095512.3667549-1-ruanjinjie@huawei.com/

Out of the curiosity (and no need to respond if you don't feel like) - 
are you using the gts helpers in some of your project(s)? I am glad 
seeing these fixes coming in and just wondered if all these bugs are 
found because these helpers are being used outside the ROHM drivers :)

Yours,
	-- Matti


  reply	other threads:[~2024-10-31  7:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-31  1:47 Zicheng Qu
2024-10-31  7:32 ` Matti Vaittinen [this message]
2024-11-01  3:49   ` Zicheng Qu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9ee46109-8503-4b5d-bfd4-45b7ac03029a@gmail.com \
    --to=mazziesaccount@gmail.com \
    --cc=jic23@kernel.org \
    --cc=judy.chenhui@huawei.com \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quzicheng@huawei.com \
    --cc=tanghui20@huawei.com \
    --cc=zhangqiao22@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®