[PATCH] scripts/kconfig: handle cases with 'option modules' defined after reference

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Currently, the following test-case causes a segfault:

config A
	tristate "A" if m

config MODULES
	boolean "MODULES"
	option modules

This is, because modules_sym is NULL until 'option modules' appears,
since commit
6902dccfda (kconfig: do not special-case 'MODULES' symbol).

The above example causes an expression of type symbol being generated
with NULL as the pointer to the symbol in menu_check_dep(), later
causing a segfault when that pointer is dereferenced.

This patch basically reverts commit 6902dccfda keeping only the change
that modules_sym references symbol 'n' as a default when 'option
modules' is not used in the config files.

Reported-by: Martin Walch <walch.martin@xxxxxx>
Signed-off-by: Dirk Gouders <dirk@xxxxxxxxxxx>
---
 scripts/kconfig/menu.c  |  9 ++++++---
 scripts/kconfig/zconf.y | 11 +++++++++--
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index db1512a..c4ec1ff 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -198,15 +198,18 @@ void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep)
 
 void menu_add_option(int token, char *arg)
 {
+	struct property *prop;
+
 	switch (token) {
 	case T_OPT_MODULES:
-		if (modules_sym)
+		if (modules_sym->prop)
 			zconf_error("symbol '%s' redefines option 'modules'"
 				    " already defined by symbol '%s'",
 				    current_entry->sym->name,
-				    modules_sym->name
+				    prop_get_symbol(modules_sym->prop)->name
 				    );
-		modules_sym = current_entry->sym;
+		prop = prop_alloc(P_DEFAULT, modules_sym);
+		prop->expr = expr_alloc_symbol(current_entry->sym);
 		break;
 	case T_OPT_DEFCONFIG_LIST:
 		if (!sym_defconfig_list)
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
index 0653886..941ec32 100644
--- a/scripts/kconfig/zconf.y
+++ b/scripts/kconfig/zconf.y
@@ -493,6 +493,9 @@ void conf_parse(const char *name)
 
 	sym_init();
 	_menu_init();
+	modules_sym = sym_lookup(NULL, 0);
+	modules_sym->type = S_BOOLEAN;
+	modules_sym->flags |= SYMBOL_AUTO;
 	rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL);
 
 	if (getenv("ZCONF_DEBUG"))
@@ -500,8 +503,12 @@ void conf_parse(const char *name)
 	zconfparse();
 	if (zconfnerrs)
 		exit(1);
-	if (!modules_sym)
-		modules_sym = sym_find( "n" );
+	if (!modules_sym->prop) {
+		struct property *prop;
+
+		prop = prop_alloc(P_DEFAULT, modules_sym);
+		prop->expr = expr_alloc_symbol(sym_find("n"));
+	}
 
 	rootmenu.prompt->text = _(rootmenu.prompt->text);
 	rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text);
-- 
1.8.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux