1
0
Fork 0

scripts/kallsyms: fix definitely-lost memory leak

[ Upstream commit 21915eca08 ]

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>
5.4-rM2-2.2.x-imx-squashed
Masahiro Yamada 2019-11-24 01:04:30 +09:00 committed by Greg Kroah-Hartman
parent 7da0d7a575
commit 70958af3e2
1 changed files with 2 additions and 0 deletions

View File

@ -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;