public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kconfig: Don't leak choice names during parsing
@ 2018-02-20 11:40 Masahiro Yamada
  2018-02-20 19:54 ` Ulf Magnusson
  2018-02-24 15:12 ` Masahiro Yamada
  0 siblings, 2 replies; 4+ messages in thread
From: Masahiro Yamada @ 2018-02-20 11:40 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Sam Ravnborg, Michal Marek, Ulf Magnusson, Randy Dunlap,
	Masahiro Yamada, Luis R. Rodriguez, linux-kernel

The named choice is not used in the kernel tree, but if it were used,
it would not be freed.

The intention of the named choice can be seen in the log of
commit 5a1aa8a1aff6 ("kconfig: add named choice group").

There is room for argument if this is useful in practice, but anyway
I am fixing the memory leak.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 scripts/kconfig/zconf.y | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
index 4be9805..4893676 100644
--- a/scripts/kconfig/zconf.y
+++ b/scripts/kconfig/zconf.y
@@ -276,6 +276,7 @@ choice: T_CHOICE word_opt T_EOL
 	sym->flags |= SYMBOL_AUTO;
 	menu_add_entry(sym);
 	menu_add_expr(P_CHOICE, NULL, NULL);
+	free($2);
 	printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno());
 };
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] kconfig: Don't leak choice names during parsing
  2018-02-20 11:40 [PATCH] kconfig: Don't leak choice names during parsing Masahiro Yamada
@ 2018-02-20 19:54 ` Ulf Magnusson
  2018-02-20 20:39   ` Sam Ravnborg
  2018-02-24 15:12 ` Masahiro Yamada
  1 sibling, 1 reply; 4+ messages in thread
From: Ulf Magnusson @ 2018-02-20 19:54 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Linux Kbuild mailing list, Sam Ravnborg, Michal Marek,
	Randy Dunlap, Luis R. Rodriguez, Linux Kernel Mailing List

On Tue, Feb 20, 2018 at 12:40 PM, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> The named choice is not used in the kernel tree, but if it were used,
> it would not be freed.
>
> The intention of the named choice can be seen in the log of
> commit 5a1aa8a1aff6 ("kconfig: add named choice group").
>
> There is room for argument if this is useful in practice, but anyway
> I am fixing the memory leak.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>
>  scripts/kconfig/zconf.y | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
> index 4be9805..4893676 100644
> --- a/scripts/kconfig/zconf.y
> +++ b/scripts/kconfig/zconf.y
> @@ -276,6 +276,7 @@ choice: T_CHOICE word_opt T_EOL
>         sym->flags |= SYMBOL_AUTO;
>         menu_add_entry(sym);
>         menu_add_expr(P_CHOICE, NULL, NULL);
> +       free($2);
>         printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno());
>  };
>
> --
> 2.7.4
>

Reviewed-by: Ulf Magnusson <ulfalizer@gmail.com>

Only place I've seen named choices in practice is in the esp-idf
project. Not sure what they're using them for.

They were handy for writing tests too. :P

Cheers,
Ulf

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kconfig: Don't leak choice names during parsing
  2018-02-20 19:54 ` Ulf Magnusson
@ 2018-02-20 20:39   ` Sam Ravnborg
  0 siblings, 0 replies; 4+ messages in thread
From: Sam Ravnborg @ 2018-02-20 20:39 UTC (permalink / raw)
  To: Ulf Magnusson
  Cc: Masahiro Yamada, Linux Kbuild mailing list, Michal Marek,
	Randy Dunlap, Luis R. Rodriguez, Linux Kernel Mailing List

On Tue, Feb 20, 2018 at 08:54:58PM +0100, Ulf Magnusson wrote:
> On Tue, Feb 20, 2018 at 12:40 PM, Masahiro Yamada
> <yamada.masahiro@socionext.com> wrote:
> > The named choice is not used in the kernel tree, but if it were used,
> > it would not be freed.
> >
> > The intention of the named choice can be seen in the log of
> > commit 5a1aa8a1aff6 ("kconfig: add named choice group").
> >
> > There is room for argument if this is useful in practice, but anyway
> > I am fixing the memory leak.
> >
> > Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> > ---
> >
> >  scripts/kconfig/zconf.y | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
> > index 4be9805..4893676 100644
> > --- a/scripts/kconfig/zconf.y
> > +++ b/scripts/kconfig/zconf.y
> > @@ -276,6 +276,7 @@ choice: T_CHOICE word_opt T_EOL
> >         sym->flags |= SYMBOL_AUTO;
> >         menu_add_entry(sym);
> >         menu_add_expr(P_CHOICE, NULL, NULL);
> > +       free($2);
> >         printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno());
> >  };
> >
> > --
> > 2.7.4
> >
> 
> Reviewed-by: Ulf Magnusson <ulfalizer@gmail.com>
> 
> Only place I've seen named choices in practice is in the esp-idf
> project. Not sure what they're using them for.

The plan with named choices was that it should
allow one to do something like this:

# in one file the choice was defined:
choice FOOBAR
prompt "foobar"

config SAMBAR
bool "bar"

endchoice


# and in another file the choice was extended:
choice FOOBAR

config SAMFOO
bool "foo"

endchoice

The user was then presented only with a single list of choices.

The idea was that this would allow better support for a base
configuration that could be extended in another file.
Think arch/Kconfig versus an arch specific Kconfig file.

But Roman nor I never got around to actually implement this.
Most likely because the need was not big enough.

	Sam

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kconfig: Don't leak choice names during parsing
  2018-02-20 11:40 [PATCH] kconfig: Don't leak choice names during parsing Masahiro Yamada
  2018-02-20 19:54 ` Ulf Magnusson
@ 2018-02-24 15:12 ` Masahiro Yamada
  1 sibling, 0 replies; 4+ messages in thread
From: Masahiro Yamada @ 2018-02-24 15:12 UTC (permalink / raw)
  To: Linux Kbuild mailing list
  Cc: Sam Ravnborg, Michal Marek, Ulf Magnusson, Randy Dunlap,
	Masahiro Yamada, Luis R. Rodriguez, Linux Kernel Mailing List

2018-02-20 20:40 GMT+09:00 Masahiro Yamada <yamada.masahiro@socionext.com>:
> The named choice is not used in the kernel tree, but if it were used,
> it would not be freed.
>
> The intention of the named choice can be seen in the log of
> commit 5a1aa8a1aff6 ("kconfig: add named choice group").
>
> There is room for argument if this is useful in practice, but anyway
> I am fixing the memory leak.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


Applied to linux-kbuild/kconfig.




-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-02-24 15:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-20 11:40 [PATCH] kconfig: Don't leak choice names during parsing Masahiro Yamada
2018-02-20 19:54 ` Ulf Magnusson
2018-02-20 20:39   ` Sam Ravnborg
2018-02-24 15:12 ` Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox