[PATCH 02/08] Fix Simple Bitmask Leaks Against: numactl-2.0.3-rc2 Add or move numa_bitmask_free() or exit via path that already frees bitmask to plug leaks. Kornilios pulled a couple of these hunks out of a single big patch that I had originally created. I figured the node_parse_*string() hunks were simple enough to fit here as well. Note: this patch leaves a bitmask leak in numa_parse_nodestring() that will be fixed in a later patch. libnuma.c | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-) Index: numactl-2.0.3-rc2/libnuma.c =================================================================== --- numactl-2.0.3-rc2.orig/libnuma.c 2009-04-27 09:33:09.000000000 -0400 +++ numactl-2.0.3-rc2/libnuma.c 2009-04-27 09:34:40.000000000 -0400 @@ -755,6 +755,7 @@ void numa_tonode_memory(void *mem, size_ nodes = numa_allocate_nodemask(); numa_bitmask_setbit(nodes, node); dombind(mem, size, bind_policy, nodes); + numa_bitmask_free(nodes); } void @@ -882,6 +883,7 @@ numa_get_interleave_mask_v1(void) copy_bitmask_to_nodemask(bmp, &mask); else copy_bitmask_to_nodemask(numa_no_nodes_ptr, &mask); + numa_bitmask_free(bmp); return mask; } __asm__(".symver numa_get_interleave_mask_v1,numa_get_interleave_mask@xxxxxxxxxxx"); @@ -1388,13 +1390,13 @@ numa_run_on_node_mask_v2(struct bitmask } err = numa_sched_setaffinity_v2_int(0, cpus); + numa_bitmask_free(cpus); + numa_bitmask_free(nodecpus); + /* used to have to consider that this could fail - it shouldn't now */ if (err < 0) { numa_error("numa_sched_setaffinity_v2_int() failed; abort\n"); - return -1; } - numa_bitmask_free(cpus); - numa_bitmask_free(nodecpus); return err; } @@ -1662,7 +1664,7 @@ numa_parse_nodestring(char *s) } } while (*s++ == ','); if (s[-1] != '\0') - return 0; + goto err; if (invert) { int i; for (i = 0; i < conf_nodes; i++) { @@ -1758,7 +1760,7 @@ numa_parse_cpustring(char *s) } } while (*s++ == ','); if (s[-1] != '\0') - return 0; + goto err; if (invert) { int i; for (i = 0; i < conf_cpus; i++) { -- To unsubscribe from this list: send the line "unsubscribe linux-numa" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html