diff mbox

opensm/osm_qos_policy.c: fix memory leak when parsing policy file

Message ID 51251DE5.2090703@dev.mellanox.co.il (mailing list archive)
State Accepted
Delegated to: Hal Rosenstock
Headers show

Commit Message

Hal Rosenstock Feb. 20, 2013, 7:03 p.m. UTC
We need to free the pkey_range_arr before parsing the qos file.

Signed-off-by: Dan Ben Yosef <danby@mellanox.com>
---

 }
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/opensm/osm_qos_policy.c b/opensm/osm_qos_policy.c
index 1751849..e61392f 100644
--- a/opensm/osm_qos_policy.c
+++ b/opensm/osm_qos_policy.c
@@ -283,15 +283,16 @@  void
osm_qos_policy_qos_level_destroy(osm_qos_level_t * p)
 	if (!p)
 		return;

-	if (p->name)
-		free(p->name);
-	if (p->use)
-		free(p->use);
+	free(p->name);
+	free(p->use);

 	for (i = 0; i < p->path_bits_range_len; i++)
 		free(p->path_bits_range_arr[i]);
-	if (p->path_bits_range_arr)
-		free(p->path_bits_range_arr);
+	free(p->path_bits_range_arr);
+
+	for(i = 0; i < p->pkey_range_len; i++)
+		free((p->pkey_range_arr[i]));
+	free(p->pkey_range_arr);

 	free(p);