[ofa-general] [PATCH] libibumad: fix memory leak
Sasha Khapyorsky
sashak at voltaire.com
Sat Dec 1 08:49:39 PST 2007
Fix memory leak - free allocated by scandir() namelist elements.
Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
libibumad/src/umad.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/libibumad/src/umad.c b/libibumad/src/umad.c
index 5b7b83e..1dc328d 100644
--- a/libibumad/src/umad.c
+++ b/libibumad/src/umad.c
@@ -177,6 +177,7 @@ get_port(char *ca_name, char *dir, int portnum, umad_port_t *port)
idx = strtoul(namelist[i]->d_name, NULL, 0);
sys_read_uint(port_dir, namelist[i]->d_name, &val);
port->pkeys[idx] = val;
+ free(namelist[i]);
}
port->pkeys_size = ret;
free(namelist);
@@ -188,8 +189,11 @@ get_port(char *ca_name, char *dir, int portnum, umad_port_t *port)
return 0;
clean:
- if (namelist)
+ if (namelist) {
+ for (i = 0; i < ret ; i++)
+ free(namelist[i]);
free(namelist);
+ }
if (port->pkeys)
free(port->pkeys);
return -EIO;
--
1.5.3.4.206.g58ba4
More information about the general
mailing list