aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2006-06-01 05:41:41 +0000
committerRoland Dreier <rolandd@cisco.com>2006-11-09 11:36:33 -0800
commita82618177859823e781fad820b1227607b2b1254 (patch)
tree629b2b6601a36c4699aa89d6927294bbff296e07
parent3efe17f3fc07db7a565489fee881e433d72fd3a6 (diff)
downloadlibibverbs-a82618177859823e781fad820b1227607b2b1254.tar.gz
Fix minor memory leaks
The result of asprintf needs to be free when no longer needed. Signed-off-by: Roland Dreier <rolandd@cisco.com>
-rw-r--r--ChangeLog4
-rw-r--r--src/device.c2
-rw-r--r--src/init.c2
3 files changed, 8 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 12ff680..41790e2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2006-05-31 Roland Dreier <rdreier@cisco.com>
+ * src/init.c (find_drivers), src/device.c (ibv_open_device): Fix
+ memleaks: the result of asprintf() needs to be freed when we're
+ done with it.
+
* examples/asyncwatch.c (event_name_str): Print human-readable
form of IBV_EVENT_CLIENT_REREGISTER.
diff --git a/src/device.c b/src/device.c
index 3ab6ceb..4eee31c 100644
--- a/src/device.c
+++ b/src/device.c
@@ -119,6 +119,8 @@ struct ibv_context *ibv_open_device(struct ibv_device *device)
* provider needs to mmap() the file.
*/
cmd_fd = open(devpath, O_RDWR);
+ free(devpath);
+
if (cmd_fd < 0)
return NULL;
diff --git a/src/init.c b/src/init.c
index 4b943b8..2e45a55 100644
--- a/src/init.c
+++ b/src/init.c
@@ -106,6 +106,8 @@ static void find_drivers(char *dir)
asprintf(&pat, "%s/*.so", dir);
ret = glob(pat, 0, NULL, &so_glob);
+ free(pat);
+
if (ret) {
if (ret != GLOB_NOMATCH)
fprintf(stderr, PFX "Warning: couldn't search %s\n", pat);