[PATCH 07/66] kconfig: gconf: fix potential memory leak in renderer_edited()

Masahiro Yamada posted 66 patches 3 months, 2 weeks ago
[PATCH 07/66] kconfig: gconf: fix potential memory leak in renderer_edited()
Posted by Masahiro Yamada 3 months, 2 weeks ago
If gtk_tree_model_get_iter() fails, gtk_tree_path_free() is not called.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/kconfig/gconf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c
index a3978d3420d1..769f38307f34 100644
--- a/scripts/kconfig/gconf.c
+++ b/scripts/kconfig/gconf.c
@@ -745,7 +745,7 @@ static void renderer_edited(GtkCellRendererText * cell,
 	struct symbol *sym;
 
 	if (!gtk_tree_model_get_iter(model2, &iter, path))
-		return;
+		goto free;
 
 	gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1);
 	sym = menu->sym;
@@ -757,6 +757,7 @@ static void renderer_edited(GtkCellRendererText * cell,
 
 	update_tree(&rootmenu, NULL);
 
+free:
 	gtk_tree_path_free(path);
 }
 
-- 
2.43.0
Re: [PATCH 07/66] kconfig: gconf: fix potential memory leak in renderer_edited()
Posted by Randy Dunlap 3 months, 1 week ago

On 6/24/25 8:04 AM, Masahiro Yamada wrote:
> If gtk_tree_model_get_iter() fails, gtk_tree_path_free() is not called.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

Acked-by: Randy Dunlap <rdunlap@infradead.org>

> ---
> 
>  scripts/kconfig/gconf.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c
> index a3978d3420d1..769f38307f34 100644
> --- a/scripts/kconfig/gconf.c
> +++ b/scripts/kconfig/gconf.c
> @@ -745,7 +745,7 @@ static void renderer_edited(GtkCellRendererText * cell,
>  	struct symbol *sym;
>  
>  	if (!gtk_tree_model_get_iter(model2, &iter, path))
> -		return;
> +		goto free;
>  
>  	gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1);
>  	sym = menu->sym;
> @@ -757,6 +757,7 @@ static void renderer_edited(GtkCellRendererText * cell,
>  
>  	update_tree(&rootmenu, NULL);
>  
> +free:
>  	gtk_tree_path_free(path);
>  }
>  

-- 
~Randy