diff mbox series

[dwarves,v4,02/10] btf_encoder: free encoder->secinfo in btf_encoder__delete

Message ID 20250107190855.2312210-3-ihor.solodrai@pm.me (mailing list archive)
State Not Applicable
Headers show
Series pahole: faster reproducible BTF encoding | expand

Commit Message

Ihor Solodrai Jan. 7, 2025, 7:09 p.m. UTC
encoder->secinfo is allocated in btf_encoder__new and is
never freed. Fix that.

Link: https://lore.kernel.org/dwarves/YiiVvWJxHUyK75b4FqlvAOnHvX9WLzCsRLG-236zf_cPZy1jmgbUq2xM4ChxRob1kaTVUdtVljtcpL2Cs3v1wXPGcP8dPeASBiYVGH3jEaQ=@pm.me/

Signed-off-by: Ihor Solodrai <ihor.solodrai@pm.me>
---
 btf_encoder.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Alan Maguire Jan. 9, 2025, 4:54 p.m. UTC | #1
On 07/01/2025 19:09, Ihor Solodrai wrote:
> encoder->secinfo is allocated in btf_encoder__new and is
> never freed. Fix that.
> 
> Link: https://lore.kernel.org/dwarves/YiiVvWJxHUyK75b4FqlvAOnHvX9WLzCsRLG-236zf_cPZy1jmgbUq2xM4ChxRob1kaTVUdtVljtcpL2Cs3v1wXPGcP8dPeASBiYVGH3jEaQ=@pm.me/
> 
> Signed-off-by: Ihor Solodrai <ihor.solodrai@pm.me>

Good catch!

Reviewed-by: Alan Maguire <alan.maguire@oracle.com>

> ---
>  btf_encoder.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/btf_encoder.c b/btf_encoder.c
> index 2e51afd..6720065 100644
> --- a/btf_encoder.c
> +++ b/btf_encoder.c
> @@ -2453,6 +2453,7 @@ void btf_encoder__delete(struct btf_encoder *encoder)
>  	btf_encoders__delete(encoder);
>  	for (shndx = 0; shndx < encoder->seccnt; shndx++)
>  		__gobuffer__delete(&encoder->secinfo[shndx].secinfo);
> +	free(encoder->secinfo);
>  	zfree(&encoder->filename);
>  	zfree(&encoder->source_filename);
>  	btf__free(encoder->btf);
diff mbox series

Patch

diff --git a/btf_encoder.c b/btf_encoder.c
index 2e51afd..6720065 100644
--- a/btf_encoder.c
+++ b/btf_encoder.c
@@ -2453,6 +2453,7 @@  void btf_encoder__delete(struct btf_encoder *encoder)
 	btf_encoders__delete(encoder);
 	for (shndx = 0; shndx < encoder->seccnt; shndx++)
 		__gobuffer__delete(&encoder->secinfo[shndx].secinfo);
+	free(encoder->secinfo);
 	zfree(&encoder->filename);
 	zfree(&encoder->source_filename);
 	btf__free(encoder->btf);