kconfig: delay symbol direct dependency initialization

This fixes the use-after-free and associated crash in kconfig introduced
in commit 246cf9c26bf11f2bffbecea6e5bd222eee7b1df8.

Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>

authored by Arnaud Lacombe and committed by Michal Marek ff5ff606 8558f59e

+2 -6
-1
scripts/kconfig/expr.h
··· 165 165 struct symbol *sym; 166 166 struct property *prompt; 167 167 struct expr *dep; 168 - struct expr *dir_dep; 169 168 unsigned int flags; 170 169 char *help; 171 170 struct file *file;
+2 -5
scripts/kconfig/menu.c
··· 107 107 void menu_add_dep(struct expr *dep) 108 108 { 109 109 current_entry->dep = expr_alloc_and(current_entry->dep, menu_check_dep(dep)); 110 - current_entry->dir_dep = current_entry->dep; 111 110 } 112 111 113 112 void menu_set_type(int type) ··· 290 291 for (menu = parent->list; menu; menu = menu->next) 291 292 menu_finalize(menu); 292 293 } else if (sym) { 293 - /* ignore inherited dependencies for dir_dep */ 294 - sym->dir_dep.expr = expr_transform(expr_copy(parent->dir_dep)); 295 - sym->dir_dep.expr = expr_eliminate_dups(sym->dir_dep.expr); 296 - 297 294 basedep = parent->prompt ? parent->prompt->visible.expr : NULL; 298 295 basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no); 299 296 basedep = expr_eliminate_dups(expr_transform(basedep)); ··· 320 325 parent->next = last_menu->next; 321 326 last_menu->next = NULL; 322 327 } 328 + 329 + sym->dir_dep.expr = parent->dep; 323 330 } 324 331 for (menu = parent->list; menu; menu = menu->next) { 325 332 if (sym && sym_is_choice(sym) &&