From: Kornilios Kourtis <kkourt@cslab.ece.ntua.gr>
To: linux-numa@vger.kernel.org
Subject: [PATCH] bitmask memory leaks
Date: Tue, 17 Mar 2009 02:52:51 +0200 [thread overview]
Message-ID: <20090317005251.GA9543@solar.cslab.ece.ntua.gr> (raw)
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
reply other threads:[~2009-03-17 0:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090317005251.GA9543@solar.cslab.ece.ntua.gr \
--to=kkourt@cslab.ece.ntua.gr \
--cc=linux-numa@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).