* [PATCH] bitmask memory leaks
@ 2009-03-17 0:52 Kornilios Kourtis
0 siblings, 0 replies; only message in thread
From: Kornilios Kourtis @ 2009-03-17 0:52 UTC (permalink / raw)
To: linux-numa
Fix bitmask memory leaks in numa_alloc_onnode() and numa_preferred()
--- libnuma.c.orig 2009-03-16 23:09:13.000000000 +0000
+++ libnuma.c 2009-03-16 23:30:45.000000000 +0000
@@ -927,8 +927,10 @@ void *numa_alloc_onnode(size_t size, int
mem = mmap(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
0, 0);
if (mem == (char *)-1)
- return NULL;
- dombind(mem, size, bind_policy, bmp);
+ mem = NULL;
+ else
+ dombind(mem, size, bind_policy, bmp);
+ numa_bitmask_free(bmp);
return mem;
}
@@ -1505,6 +1507,7 @@ int numa_run_on_node(int node)
int numa_preferred(void)
{
int policy;
+ int ret;
struct bitmask *bmp;
bmp = numa_allocate_nodemask();
@@ -1513,12 +1516,17 @@ int numa_preferred(void)
int i;
int max = numa_num_possible_nodes();
for (i = 0; i < max ; i++)
- if (numa_bitmask_isbitset(bmp, i))
- return i;
+ if (numa_bitmask_isbitset(bmp, i)){
+ ret = i;
+ goto end;
+ }
}
/* could read the current CPU from /proc/self/status. Probably
not worth it. */
- return 0; /* or random one? */
+ ret = 0; /* or random one? */
+end:
+ numa_bitmask_free(bmp);
+ return ret;
}
void numa_set_preferred(int node)
--
Kornilios Kourtis
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-03-17 0:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-17 0:52 [PATCH] bitmask memory leaks Kornilios Kourtis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).