]> git.openfabrics.org - ~shefty/libibverbs.git/commitdiff
Fix memory leak in ibv_read_sysfs_file()
authorRoland Dreier <rolandd@cisco.com>
Wed, 12 Apr 2006 04:41:36 +0000 (04:41 +0000)
committerRoland Dreier <rolandd@cisco.com>
Thu, 9 Nov 2006 19:36:00 +0000 (11:36 -0800)
Signed-off-by: Roland Dreier <rolandd@cisco.com>
ChangeLog
src/sysfs.c

index d4abeaee17b6229cff6becf297a49dac08891073..ee28f4d393fef12238242f9481f42b9c379fef28 100644 (file)
--- 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.
index e97f0e8779e07a0c73874a58e6d2ca2e923df440..52fbd5a536fe514031af5c0dd8d3c0f1b98e94dd 100644 (file)
@@ -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);