public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kconfig: forbid multiple entries with the same symbol in a choice
@ 2026-03-30 11:57 Masahiro Yamada
  2026-03-30 14:14 ` Nathan Chancellor
  2026-04-03 19:15 ` Nicolas Schier
  0 siblings, 2 replies; 3+ messages in thread
From: Masahiro Yamada @ 2026-03-30 11:57 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Masahiro Yamada, Nathan Chancellor, Nicolas Schier, linux-kernel

Commit 6a859f1a19d1 ("powerpc: unify two CONFIG_POWERPC64_CPU entries
in the same choice block") removed the only occurrence of this tricky
use case.

Disallow this pattern in choice_check_sanity() and revert commit
4d46b5b623e0 ("kconfig: fix infinite loop in sym_calc_choice()").

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

 scripts/kconfig/parser.y | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y
index 6d1bbee38f5d..5fb6f07b6ad2 100644
--- a/scripts/kconfig/parser.y
+++ b/scripts/kconfig/parser.y
@@ -159,14 +159,8 @@ config_stmt: config_entry_start config_option_list
 			yynerrs++;
 		}
 
-		/*
-		 * If the same symbol appears twice in a choice block, the list
-		 * node would be added twice, leading to a broken linked list.
-		 * list_empty() ensures that this symbol has not yet added.
-		 */
-		if (list_empty(&current_entry->sym->choice_link))
-			list_add_tail(&current_entry->sym->choice_link,
-				      &current_choice->choice_members);
+		list_add_tail(&current_entry->sym->choice_link,
+			      &current_choice->choice_members);
 	}
 
 	printd(DEBUG_PARSE, "%s:%d:endconfig\n", cur_filename, cur_lineno);
@@ -546,11 +540,10 @@ static int choice_check_sanity(const struct menu *menu)
 			ret = -1;
 		}
 
-		if (prop->menu != menu && prop->type == P_PROMPT &&
-		    prop->menu->parent != menu->parent) {
+		if (prop->menu != menu && prop->type == P_PROMPT) {
 			fprintf(stderr, "%s:%d: error: %s",
 				prop->filename, prop->lineno,
-				"choice value has a prompt outside its choice group\n");
+				"choice value must not have a prompt in another entry\n");
 			ret = -1;
 		}
 	}
-- 
2.43.0


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

* Re: [PATCH] kconfig: forbid multiple entries with the same symbol in a choice
  2026-03-30 11:57 [PATCH] kconfig: forbid multiple entries with the same symbol in a choice Masahiro Yamada
@ 2026-03-30 14:14 ` Nathan Chancellor
  2026-04-03 19:15 ` Nicolas Schier
  1 sibling, 0 replies; 3+ messages in thread
From: Nathan Chancellor @ 2026-03-30 14:14 UTC (permalink / raw)
  To: Masahiro Yamada; +Cc: linux-kbuild, Nicolas Schier, linux-kernel

On Mon, Mar 30, 2026 at 08:57:35PM +0900, Masahiro Yamada wrote:
> Commit 6a859f1a19d1 ("powerpc: unify two CONFIG_POWERPC64_CPU entries
> in the same choice block") removed the only occurrence of this tricky
> use case.
> 
> Disallow this pattern in choice_check_sanity() and revert commit
> 4d46b5b623e0 ("kconfig: fix infinite loop in sym_calc_choice()").
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

Yeah, definitely seems like a reasonable restriction.

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
> 
>  scripts/kconfig/parser.y | 15 ++++-----------
>  1 file changed, 4 insertions(+), 11 deletions(-)
> 
> diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y
> index 6d1bbee38f5d..5fb6f07b6ad2 100644
> --- a/scripts/kconfig/parser.y
> +++ b/scripts/kconfig/parser.y
> @@ -159,14 +159,8 @@ config_stmt: config_entry_start config_option_list
>  			yynerrs++;
>  		}
>  
> -		/*
> -		 * If the same symbol appears twice in a choice block, the list
> -		 * node would be added twice, leading to a broken linked list.
> -		 * list_empty() ensures that this symbol has not yet added.
> -		 */
> -		if (list_empty(&current_entry->sym->choice_link))
> -			list_add_tail(&current_entry->sym->choice_link,
> -				      &current_choice->choice_members);
> +		list_add_tail(&current_entry->sym->choice_link,
> +			      &current_choice->choice_members);
>  	}
>  
>  	printd(DEBUG_PARSE, "%s:%d:endconfig\n", cur_filename, cur_lineno);
> @@ -546,11 +540,10 @@ static int choice_check_sanity(const struct menu *menu)
>  			ret = -1;
>  		}
>  
> -		if (prop->menu != menu && prop->type == P_PROMPT &&
> -		    prop->menu->parent != menu->parent) {
> +		if (prop->menu != menu && prop->type == P_PROMPT) {
>  			fprintf(stderr, "%s:%d: error: %s",
>  				prop->filename, prop->lineno,
> -				"choice value has a prompt outside its choice group\n");
> +				"choice value must not have a prompt in another entry\n");
>  			ret = -1;
>  		}
>  	}
> -- 
> 2.43.0
> 

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

* Re: [PATCH] kconfig: forbid multiple entries with the same symbol in a choice
  2026-03-30 11:57 [PATCH] kconfig: forbid multiple entries with the same symbol in a choice Masahiro Yamada
  2026-03-30 14:14 ` Nathan Chancellor
@ 2026-04-03 19:15 ` Nicolas Schier
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Schier @ 2026-04-03 19:15 UTC (permalink / raw)
  To: linux-kbuild, Masahiro Yamada
  Cc: Nicolas Schier, Nathan Chancellor, linux-kernel

On Mon, 30 Mar 2026 20:57:35 +0900, Masahiro Yamada wrote:
> Commit 6a859f1a19d1 ("powerpc: unify two CONFIG_POWERPC64_CPU entries
> in the same choice block") removed the only occurrence of this tricky
> use case.
> 
> Disallow this pattern in choice_check_sanity() and revert commit
> 4d46b5b623e0 ("kconfig: fix infinite loop in sym_calc_choice()").
> 
> [...]

Applied to kbuild/linux.git (kbuild-next-unstable), thanks!

[1/1] kconfig: forbid multiple entries with the same symbol in a choice
      https://git.kernel.org/kbuild/c/e967588a

Please look out for regression or issue reports or other follow up
comments, as they may result in the patch/series getting dropped,
reverted or modified (e.g. trailers). Patches applied to the
kbuild-next-unstable branch are accepted pending wider testing in
linux-next and any post-commit review; they will generally be moved
to the kbuild-next branch in about a week if no issues are found.

Best regards,
-- 
Nicolas


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

end of thread, other threads:[~2026-04-03 19:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-30 11:57 [PATCH] kconfig: forbid multiple entries with the same symbol in a choice Masahiro Yamada
2026-03-30 14:14 ` Nathan Chancellor
2026-04-03 19:15 ` Nicolas Schier

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