Skip to content

Commit

Permalink
numactl.c: prevent memleak from cpubuff->maskp and free value mask
Browse files Browse the repository at this point in the history
numactl -C command will free cpubuff but not free cpubuff->maskp, it
will cause memleak. value mask in numactl main function will no longer
be used after argument parsing, it can free.
  • Loading branch information
Chunsheng Luo authored and andikleen committed Sep 4, 2021
1 parent 4ee5e0c commit 4eb9618
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion numactl.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ int main(int ac, char **av)
did_node_cpu_parse = 1;
numa_sched_setaffinity(0, cpubuf);
checkerror("sched_setaffinity");
free(cpubuf);
numa_bitmask_free(cpubuf);
break;
}
case 'm': /* --membind */
Expand Down Expand Up @@ -645,6 +645,8 @@ int main(int ac, char **av)
}
}

numa_bitmask_free(mask);

av += optind;
ac -= optind;

Expand Down

0 comments on commit 4eb9618

Please sign in to comment.