Skip to contentSkip to conversation

infiniband-diags/libibnetdisc/ibnetdisc_cache.c: Fix a couple of memory leaks

PATCH Applied Hal Rosenstock 2 participants 2 messages Jun 8, 2011 – Jun 10, 2011 1 message not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 infiniband-diags/libibnetdisc/ibnetdisc_cache.c: Fix a couple of memory leaks

---

libibnetdisc/src/ibnetdisc_cache.c +2 -0
index 199bf33..2690373 100644
@@ -326,6 +326,7 @@ static int _load_node(int fd, ibnd_fabric_cache_t * fabric_cache)
 	node = (ibnd_node_t *) malloc(sizeof(ibnd_node_t));
 	if (!node) {
 		IBND_DEBUG("OOM: node\n");
+		free(node_cache);
 		return -1;
 	}
 	memset(node, '\0', sizeof(ibnd_node_t));
@@ -426,6 +427,7 @@ static int _load_port(int fd, ibnd_fabric_cache_t * fabric_cache)
 	port = (ibnd_port_t *) malloc(sizeof(ibnd_port_t));
 	if (!port) {
 		IBND_DEBUG("OOM: port\n");
+		free(port_cache);
 		return -1;
 	}
 	memset(port, '\0', sizeof(ibnd_port_t));

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Applied
#2 lore raw
In reply to a message not in the archive
Quoted 2 lines · On Wed, 8 Jun 2011 05:47:34 -0700 Hal Rosenstock…

Thanks applied,
Ira

Quoted 21 lines

---

libibnetdisc/src/ibnetdisc_cache.c +2 -0
index 199bf33..2690373 100644
@@ -326,6 +326,7 @@ static int _load_node(int fd, ibnd_fabric_cache_t * fabric_cache)
 	node = (ibnd_node_t *) malloc(sizeof(ibnd_node_t));
 	if (!node) {
 		IBND_DEBUG("OOM: node\n");
+		free(node_cache);
 		return -1;
 	}
 	memset(node, '\0', sizeof(ibnd_node_t));
@@ -426,6 +427,7 @@ static int _load_port(int fd, ibnd_fabric_cache_t * fabric_cache)
 	port = (ibnd_port_t *) malloc(sizeof(ibnd_port_t));
 	if (!port) {
 		IBND_DEBUG("OOM: port\n");
+		free(port_cache);
 		return -1;
 	}
 	memset(port, '\0', sizeof(ibnd_port_t));
Signature · 9 lines
Ira Weiny
Math Programmer/Computer Scientist
Lawrence Livermore National Lab
925-423-8008
[email protected]
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html