Skip to content

Commit

Permalink
ovs-thread: Fix memory leak in thread exit.
Browse files Browse the repository at this point in the history
'n' is the number of keys, which are grouped into blocks of L2_SIZE
indexes.  Even if only one key in a block is allocated, the whole block has
a pointer to it that must be freed.  Thus, we need to round up instead of
down.

Reported-at: openvswitch#87
Signed-off-by: Ben Pfaff <[email protected]>
Acked-by: Jarno Rajahalme <[email protected]>
  • Loading branch information
blp committed Nov 10, 2015
1 parent b863fb6 commit 5657f68
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ovs-thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ ovsthread_key_destruct__(void *slots_)
n = n_keys;
ovs_mutex_unlock(&key_mutex);

for (i = 0; i < n / L2_SIZE; i++) {
for (i = 0; i < DIV_ROUND_UP(n, L2_SIZE); i++) {
free(slots->p1[i]);
}
free(slots);
Expand Down

0 comments on commit 5657f68

Please sign in to comment.