[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a760c03b-06bf-a7c0-d046-54619951761e@pengutronix.de>
Date: Sat, 20 Nov 2021 08:08:31 +0100
From: Ahmad Fatoum <a.fatoum@...gutronix.de>
To: Sohaib Mohamed <sohaib.amhmd@...il.com>, jolsa@...hat.com
Cc: acme@...nel.org, irogers@...gle.com, jolsa@...nel.org,
linux-kernel@...r.kernel.org, namhyung@...nel.org,
songliubraving@...com
Subject: Re: [PATCH] Fixup: perf bench: Fix two memory leaks detected with
ASan
On 20.11.21 07:53, Ahmad Fatoum wrote:
>> + snd_ctx_arr[total_counter] = snd_ctx;
>
> You are storing at snd_ctx_arr[num_fd] each time, so you will leak
> all context, except for the last one.
Oh, it's more subtle than that. total_counter is of course incremented
every time in the previous loop, so you will have num_fd times NULL
(from static initialization) then a pointer to an allocation and so on.
That works by the looks of it, but looks quite strange.
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Powered by blists - more mailing lists