svn commit: r341895 - stable/11/contrib/ofed/libibverbs
Hans Petter Selasky
hselasky at FreeBSD.org
Wed Dec 12 11:38:01 UTC 2018
Author: hselasky
Date: Wed Dec 12 11:38:00 2018
New Revision: 341895
URL: https://svnweb.freebsd.org/changeset/base/341895
Log:
MFC r341540:
libibverbs: Fix memory leak in ibv_read_sysfs_file().
Testing packetdrill using valgrind resulted in finding a memory leak in
ibv_read_sysfs_file(). The attached patch fixes it.
Submitted by: tuexen@
Sponsored by: Mellanox Technologies
Modified:
stable/11/contrib/ofed/libibverbs/sysfs.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/contrib/ofed/libibverbs/sysfs.c
==============================================================================
--- stable/11/contrib/ofed/libibverbs/sysfs.c Wed Dec 12 11:37:43 2018 (r341894)
+++ stable/11/contrib/ofed/libibverbs/sysfs.c Wed Dec 12 11:38:00 2018 (r341895)
@@ -79,7 +79,7 @@ int ibv_read_sysfs_file(const char *dir, const char *f
char *buf, size_t size)
{
char *path, *s;
- int fd;
+ int ret;
size_t len;
if (asprintf(&path, "%s/%s", dir, file) < 0)
@@ -89,11 +89,12 @@ int ibv_read_sysfs_file(const char *dir, const char *f
if (*s == '/')
*s = '.';
- len = size;
- if (sysctlbyname(&path[1], buf, &len, NULL, 0) == -1)
- return -1;
-
+ len = size;
+ ret = sysctlbyname(&path[1], buf, &len, NULL, 0);
free(path);
+
+ if (ret == -1)
+ return -1;
if (len > 0 && buf[len - 1] == '\n')
buf[--len] = '\0';
More information about the svn-src-stable
mailing list