summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2019-11-24 01:04:30 +0900
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-01-04 19:18:23 +0100
commit70958af3e2f9f2770eb5653dcf4904ee7d696963 (patch)
tree62fba284f9b17a3232e1d9885aa458fcde9d29f2 /scripts
parent7da0d7a575434fb82472a894960152c8c6b30347 (diff)
downloadlinux-stable-70958af3e2f9f2770eb5653dcf4904ee7d696963.tar.gz
linux-stable-70958af3e2f9f2770eb5653dcf4904ee7d696963.tar.bz2
linux-stable-70958af3e2f9f2770eb5653dcf4904ee7d696963.zip
scripts/kallsyms: fix definitely-lost memory leak
[ Upstream commit 21915eca088dc271c970e8351290e83d938114ac ] build_initial_tok_table() overwrites unused sym_entry to shrink the table size. Before the entry is overwritten, table[i].sym must be freed since it is malloc'ed data. This fixes the 'definitely lost' report from valgrind. I ran valgrind against x86_64_defconfig of v5.4-rc8 kernel, and here is the summary: [Before the fix] LEAK SUMMARY: definitely lost: 53,184 bytes in 2,874 blocks [After the fix] LEAK SUMMARY: definitely lost: 0 bytes in 0 blocks Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/kallsyms.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
index ae6504d07fd6..fb15f09e0e38 100644
--- a/scripts/kallsyms.c
+++ b/scripts/kallsyms.c
@@ -489,6 +489,8 @@ static void build_initial_tok_table(void)
table[pos] = table[i];
learn_symbol(table[pos].sym, table[pos].len);
pos++;
+ } else {
+ free(table[i].sym);
}
}
table_cnt = pos;