aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2006-04-12 04:41:36 +0000
committerRoland Dreier <rolandd@cisco.com>2006-11-09 11:36:00 -0800
commit68d8e8913fab46401f99bbf7643c90cc4ad63647 (patch)
tree8bb34b3f943e346ca693dde17ae967221e81d1a2
parent50c7daf5981e73e37d052ee223ed54dd6539c846 (diff)
downloadlibibverbs-68d8e8913fab46401f99bbf7643c90cc4ad63647.tar.gz
Fix memory leak in ibv_read_sysfs_file()
Signed-off-by: Roland Dreier <rolandd@cisco.com>
-rw-r--r--ChangeLog2
-rw-r--r--src/sysfs.c4
2 files changed, 5 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index d4abeae..ee28f4d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2006-04-11 Roland Dreier <rdreier@cisco.com>
+ * src/sysfs.c (ibv_read_sysfs_file): Fix memory leak if open fails.
+
* src/device.c (ibv_get_device_guid), src/verbs.c (ibv_query_gid,
ibv_query_pkey), src/init.c (init_drivers, check_abi_version): Use
libibverbs functions instead of libsysfs functions to get to sysfs.
diff --git a/src/sysfs.c b/src/sysfs.c
index e97f0e8..52fbd5a 100644
--- a/src/sysfs.c
+++ b/src/sysfs.c
@@ -86,8 +86,10 @@ int ibv_read_sysfs_file(const char *dir, const char *file,
asprintf(&path, "%s/%s", dir, file);
fd = open(path, O_RDONLY);
- if (fd < 0)
+ if (fd < 0) {
+ free(path);
return -1;
+ }
len = read(fd, buf, size);