Skip to content

Commit

Permalink
scripts/kallsyms: fix definitely-lost memory leak
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
masahir0y committed Nov 25, 2019
1 parent 1ef26b7 commit 21915ec
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions scripts/kallsyms.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,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;
Expand Down

0 comments on commit 21915ec

Please sign in to comment.