Skip to content

Commit

Permalink
shm.c: fix memleak in verify_shm()
Browse files Browse the repository at this point in the history
Signed-off-by: Pingfan Liu <piliu@redhat.com>
  • Loading branch information
Pingfan Liu authored and andikleen committed Jun 18, 2021
1 parent 7b5f3e9 commit 8ae7521
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions shm.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,23 +273,23 @@ void verify_shm(int policy, struct bitmask *nodes)
int pol2;
struct bitmask *nodes2;

nodes2 = numa_allocate_nodemask();

if (policy == MPOL_INTERLEAVE) {
if (get_mempolicy(&ilnode, NULL, 0, shmptr,
MPOL_F_ADDR|MPOL_F_NODE)
< 0)
err("get_mempolicy");
}

nodes2 = numa_allocate_nodemask();

for (p = shmptr; p - (char *)shmptr < shmlen; p += shm_pagesize) {
if (get_mempolicy(&pol2, nodes2->maskp, nodes2->size, p,
MPOL_F_ADDR) < 0)
err("get_mempolicy");
if (pol2 != policy) {
vwarn(p, "wrong policy %s, expected %s\n",
policy_name(pol2), policy_name(policy));
return;
goto out;
}
if (memcmp(nodes2, nodes, numa_bitmask_nbytes(nodes))) {
vwarn(p, "mismatched node mask\n");
Expand All @@ -307,7 +307,7 @@ void verify_shm(int policy, struct bitmask *nodes)
if (node != ilnode) {
vwarn(p, "expected interleave node %d, got %d\n",
ilnode,node);
return;
goto out;
}
ilnode = interleave_next(ilnode, nodes2);
break;
Expand All @@ -325,4 +325,6 @@ void verify_shm(int policy, struct bitmask *nodes)
}
}

out:
numa_free_nodemask(nodes2);
}

0 comments on commit 8ae7521

Please sign in to comment.