acrn-kernel/scripts/kconfig
Masahiro Yamada 18209382db kconfig: fix memory leak from range properties
[ Upstream commit ae1eff0349f2e908fc083630e8441ea6dc434dc0 ]

Currently, sym_validate_range() duplicates the range string using
xstrdup(), which is overwritten by a subsequent sym_calc_value() call.
It results in a memory leak.

Instead, only the pointer should be copied.

Below is a test case, with a summary from Valgrind.

[Test Kconfig]

  config FOO
          int "foo"
          range 10 20

[Test .config]

  CONFIG_FOO=0

[Before]

  LEAK SUMMARY:
     definitely lost: 3 bytes in 1 blocks
     indirectly lost: 0 bytes in 0 blocks
       possibly lost: 0 bytes in 0 blocks
     still reachable: 17,465 bytes in 21 blocks
          suppressed: 0 bytes in 0 blocks

[After]

  LEAK SUMMARY:
     definitely lost: 0 bytes in 0 blocks
     indirectly lost: 0 bytes in 0 blocks
       possibly lost: 0 bytes in 0 blocks
     still reachable: 17,462 bytes in 20 blocks
          suppressed: 0 bytes in 0 blocks

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-12-13 18:39:04 +01:00
..
lxdialog
tests
.gitignore
Makefile
conf.c
confdata.c
expr.c
expr.h
gconf-cfg.sh
gconf.c
gconf.glade
images.c
images.h
internal.h
lexer.l
list.h
lkc.h
lkc_proto.h
mconf-cfg.sh
mconf.c
menu.c
merge_config.sh
nconf-cfg.sh
nconf.c
nconf.gui.c
nconf.h
parser.y
preprocess.c
qconf-cfg.sh
qconf.cc
qconf.h
streamline_config.pl
symbol.c
util.c