diff mbox

opensm/osm_qos_policy.c: fix segmentation fault on osm_qos_policy_match_rule_destroy (osm_qos_policy.c)

Message ID 1359984011-30753-1-git-send-email-alexne@mellanox.com (mailing list archive)
State Accepted
Delegated to: Hal Rosenstock
Headers show

Commit Message

Alex Netes Feb. 4, 2013, 1:20 p.m. UTC
From: Shlomi Nimrodi <shlomin@mellanox.com>

Signed-off-by: Shlomi Nimrodi <shlomin@mellanox.com>
Signed-off-by: Alex Netes <alexne@mellanox.com>
---
 opensm/osm_qos_policy.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)
diff mbox

Patch

diff --git a/opensm/osm_qos_policy.c b/opensm/osm_qos_policy.c
index c8526b9..ad5eaa0 100644
--- a/opensm/osm_qos_policy.c
+++ b/opensm/osm_qos_policy.c
@@ -373,20 +373,23 @@  void osm_qos_policy_match_rule_destroy(osm_qos_match_rule_t * p)
 	if (p->use)
 		free(p->use);
 
-	for (i = 0; i < p->service_id_range_len; i++)
-		free(p->service_id_range_arr[i]);
-	if (p->service_id_range_arr)
+	if (p->service_id_range_arr) {
+		for (i = 0; i < p->service_id_range_len; i++)
+			free(p->service_id_range_arr[i]);
 		free(p->service_id_range_arr);
+	}
 
-	for (i = 0; i < p->qos_class_range_len; i++)
-		free(p->qos_class_range_arr[i]);
-	if (p->qos_class_range_arr)
+	if (p->qos_class_range_arr) {
+		for (i = 0; i < p->qos_class_range_len; i++)
+			free(p->qos_class_range_arr[i]);
 		free(p->qos_class_range_arr);
+	}
 
-	for (i = 0; i < p->pkey_range_len; i++)
-		free(p->pkey_range_arr[i]);
-	if (p->pkey_range_arr)
+	if (p->pkey_range_arr) {
+		for (i = 0; i < p->pkey_range_len; i++)
+			free(p->pkey_range_arr[i]);
 		free(p->pkey_range_arr);
+	}
 
 	cl_list_apply_func(&p->source_list, __free_single_element, NULL);
 	cl_list_remove_all(&p->source_list);