]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
scripts/kallsyms: fix definitely-lost memory leak
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Sat, 23 Nov 2019 16:04:30 +0000 (01:04 +0900)
committerKhalid Elmously <khalid.elmously@canonical.com>
Wed, 29 Jan 2020 04:47:27 +0000 (23:47 -0500)
BugLink: https://bugs.launchpad.net/bugs/1860602
[ 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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
scripts/kallsyms.c

index 2052a0afb079dba7281b540692511d2e556c403a..aec7b79d99d1bc3ab2b87aaa38e7754ba8418eb5 100644 (file)
@@ -510,6 +510,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;