diff mbox

[02/10] opensm/osm_ucast_dfsssp.c : Fix resource leak

Message ID 1358872753-16885-1-git-send-email-domke.j.aa@m.titech.ac.jp (mailing list archive)
State Accepted
Delegated to: Alex Netes
Headers show

Commit Message

Jens Domke Jan. 22, 2013, 4:39 p.m. UTC
From: Dan Ben Yosef <danby@dev.mellanox.co.il>

Variable "head" going out of scope leaks the storage it points to.

Signed-off-by: Dan Ben Yosef <danby@dev.mellanox.co.il>
Signed-off-by: Jens Domke <domke.j.aa@m.titech.ac.jp>
---
 opensm/osm_ucast_dfsssp.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/opensm/osm_ucast_dfsssp.c b/opensm/osm_ucast_dfsssp.c
index ff525ea..013bad4 100644
--- a/opensm/osm_ucast_dfsssp.c
+++ b/opensm/osm_ucast_dfsssp.c
@@ -1161,6 +1161,11 @@  static int dfsssp_build_graph(void *context)
 				OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
 					"ERR AD08: cannot allocate memory for a link\n");
 				dfsssp_context_destroy(context);
+				while (head) {
+					link = head;
+					head = head->next;
+					free(link);
+                                }
 				return 1;
 			}
 			link = link->next;