Date: Wed, 5 Dec 2018 13:28:17 +0000 (UTC) From: Slava Shwartsman <slavash@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r341540 - head/contrib/ofed/libibverbs Message-ID: <201812051328.wB5DSHqm070684@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: slavash Date: Wed Dec 5 13:28:17 2018 New Revision: 341540 URL: https://svnweb.freebsd.org/changeset/base/341540 Log: 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@ Approved by: hselasky (mentor) MFC after: 1 week Sponsored by: Mellanox Technologies Modified: head/contrib/ofed/libibverbs/sysfs.c Modified: head/contrib/ofed/libibverbs/sysfs.c ============================================================================== --- head/contrib/ofed/libibverbs/sysfs.c Wed Dec 5 13:27:48 2018 (r341539) +++ head/contrib/ofed/libibverbs/sysfs.c Wed Dec 5 13:28:17 2018 (r341540) @@ -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';
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201812051328.wB5DSHqm070684>