summaryrefslogtreecommitdiffstats
path: root/scripts/kconfig
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2017-10-08 19:35:46 +0200
committerMasahiro Yamada <yamada.masahiro@socionext.com>2018-01-21 16:49:27 +0100
commit7cf33f88e2941051309e094e2fafd80f364735f2 (patch)
tree9fc37953eabc513ef46a9ccaa44ee5655a811a14 /scripts/kconfig
parentkconfig: Fix expr_free() E_NOT leak (diff)
downloadlinux-7cf33f88e2941051309e094e2fafd80f364735f2.tar.xz
linux-7cf33f88e2941051309e094e2fafd80f364735f2.zip
kconfig: Fix choice symbol expression leak
When propagating dependencies from parents after parsing, an expression node is allocated if the parent symbol is a 'choice'. This node was never freed. Outline of leak: if (sym && sym_is_choice(sym)) { ... *Allocate (in this case only)* parentdep = expr_alloc_symbol(sym); } else if (parent->prompt) parentdep = parent->prompt->visible.expr; else parentdep = parent->dep; for (menu = parent->list; menu; menu = menu->next) { ... *Copy* basedep = expr_alloc_and(expr_copy(parentdep), basedep); ... } *parentdep lost if the parent is a choice!* Fix by freeing 'parentdep' after the loop if the parent symbol is a choice. Note that this only frees the expression node and not the choice symbol itself. Summary from Valgrind on 'menuconfig' (ARCH=x86) before the fix: LEAK SUMMARY: definitely lost: 1,608 bytes in 67 blocks ... Summary after the fix: LEAK SUMMARY: definitely lost: 0 bytes in 0 blocks ... Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'scripts/kconfig')
-rw-r--r--scripts/kconfig/menu.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index 5b2415991c3e..41c79bef3d07 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -408,6 +408,9 @@ void menu_finalize(struct menu *parent)
}
}
+ if (sym && sym_is_choice(sym))
+ expr_free(parentdep);
+
/*
* Recursively process children in the same fashion before
* moving on