linux/scripts/kconfig
Masahiro Yamada 94e5ed1620 kconfig: fix memory leak from range properties
[ Upstream commit ae1eff0349 ]

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:36:32 +01:00
..
lxdialog
tests
.gitignore
conf.c
confdata.c kconfig: Update config changed flag before calling callback 2023-03-22 13:31:29 +01:00
expr.c
expr.h
gconf-cfg.sh kbuild: Allow kernel installation packaging to override pkg-config 2023-02-01 08:27:30 +01:00
gconf.c
gconf.glade
images.c
images.h
internal.h
lexer.l
list.h
lkc_proto.h
lkc.h
Makefile
mconf-cfg.sh kbuild: Allow kernel installation packaging to override pkg-config 2023-02-01 08:27:30 +01:00
mconf.c
menu.c
merge_config.sh
nconf-cfg.sh kbuild: Allow kernel installation packaging to override pkg-config 2023-02-01 08:27:30 +01:00
nconf.c
nconf.gui.c
nconf.h
parser.y
preprocess.c kconfig: fix possible buffer overflow 2023-09-19 12:22:56 +02:00
qconf-cfg.sh kbuild: Allow kernel installation packaging to override pkg-config 2023-02-01 08:27:30 +01:00
qconf.cc
qconf.h
streamline_config.pl
symbol.c kconfig: fix memory leak from range properties 2023-12-13 18:36:32 +01:00
util.c