diff mbox

opensm/osm_congestion_control.c: fix use-after-free found by coverity

Message ID 1359984011-30753-2-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: Ilya Nelkenbaum <ilyan@mellanox.com>

Read from pointer "p_madw" after free

Signed-off-by: Ilya Nelkenbaum <ilyan@mellanox.com>
Signed-off-by: Alex Netes <alexne@mellanox.com>
---
 opensm/osm_congestion_control.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
diff mbox

Patch

diff --git a/opensm/osm_congestion_control.c b/opensm/osm_congestion_control.c
index e103ab1..17af407 100644
--- a/opensm/osm_congestion_control.c
+++ b/opensm/osm_congestion_control.c
@@ -521,6 +521,7 @@  static void cc_poller_send(osm_congestion_control_t *p_cc,
 {
 	osm_subn_opt_t *p_opt = &p_cc->subn->opt;
 	ib_api_status_t status;
+	osm_madw_context_t mad_context = p_madw->context;
 
 	status = osm_vendor_send(p_cc->bind_handle, p_madw, TRUE);
 	if (status == IB_SUCCESS) {
@@ -530,15 +531,11 @@  static void cc_poller_send(osm_congestion_control_t *p_cc,
 			cl_event_wait_on(&p_cc->sig_mads_on_wire_continue,
 					 EVENT_NO_TIMEOUT,
 					 TRUE);
-	}
-	else {
-		osm_madw_context_t *mad_context = &p_madw->context;
-
+	} else
 		OSM_LOG(p_cc->log, OSM_LOG_ERROR, "ERR C104: "
 			"send failed to node 0x%" PRIx64 "port %u\n",
-			mad_context->cc_context.node_guid,
-			mad_context->cc_context.port);
-	}
+			mad_context.cc_context.node_guid,
+			mad_context.cc_context.port);
 }
 
 static void cc_poller(void *p_ptr)