diff options
author | Roland Dreier <rolandd@cisco.com> | 2006-06-01 05:41:41 +0000 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2006-11-09 11:36:33 -0800 |
commit | a82618177859823e781fad820b1227607b2b1254 (patch) | |
tree | 629b2b6601a36c4699aa89d6927294bbff296e07 | |
parent | 3efe17f3fc07db7a565489fee881e433d72fd3a6 (diff) | |
download | libibverbs-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-- | ChangeLog | 4 | ||||
-rw-r--r-- | src/device.c | 2 | ||||
-rw-r--r-- | src/init.c | 2 |
3 files changed, 8 insertions, 0 deletions
@@ -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; @@ -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); |