kconfig: Fix expr_free() E_NOT leak
authorUlf Magnusson <ulfalizer@gmail.com>
Sun, 8 Oct 2017 17:35:45 +0000 (19:35 +0200)
committerChristian Lamparter <chunkeey@gmail.com>
Sun, 10 Feb 2019 20:46:56 +0000 (21:46 +0100)
commitc1c9e127824bb32ed33b93898eba5e9d9926899c
treedb60c9db8dd813b77f4ac65aaa32e65839d7546c
parent43aa2e536b483b7b4b4b29776fabcb1bc2ca4d02
kconfig: Fix expr_free() E_NOT leak

Only the E_NOT operand and not the E_NOT node itself was freed, due to
accidentally returning too early in expr_free(). Outline of leak:

switch (e->type) {
...
case E_NOT:
expr_free(e->left.expr);
return;
...
}
*Never reached, 'e' leaked*
free(e);

Fix by changing the 'return' to a 'break'.

Summary from Valgrind on 'menuconfig' (ARCH=x86) before the fix:

LEAK SUMMARY:
   definitely lost: 44,448 bytes in 1,852 blocks
   ...

Summary after the fix:

LEAK SUMMARY:
   definitely lost: 1,608 bytes in 67 blocks
   ...

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
config/expr.c