diff mbox

[04/10] opensm/osm_ucast_dfsssp.c : fix dereference before null check

Message ID 1358872807-16942-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:40 p.m. UTC
From: Dan Ben Yosef <danby@dev.mellanox.co.il>

Dereferencing "dfsssp_ctx" before a null check.

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 |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/opensm/osm_ucast_dfsssp.c b/opensm/osm_ucast_dfsssp.c
index af1b062..f88382b 100644
--- a/opensm/osm_ucast_dfsssp.c
+++ b/opensm/osm_ucast_dfsssp.c
@@ -2069,14 +2069,16 @@  static uint8_t get_dfsssp_sl(void *context, uint8_t hint_for_default_sl,
 			     const ib_net16_t slid, const ib_net16_t dlid)
 {
 	dfsssp_context_t *dfsssp_ctx = (dfsssp_context_t *) context;
-	osm_ucast_mgr_t *p_mgr = (osm_ucast_mgr_t *) dfsssp_ctx->p_mgr;
 	osm_port_t *src_port, *dest_port;
 	vltable_t *srcdest2vl_table = NULL;
+	osm_ucast_mgr_t *p_mgr = NULL;
 	int32_t res = 0;
 
 	if (dfsssp_ctx
-	    && dfsssp_ctx->routing_type == OSM_ROUTING_ENGINE_TYPE_DFSSSP)
+	    && dfsssp_ctx->routing_type == OSM_ROUTING_ENGINE_TYPE_DFSSSP) {
+		p_mgr = (osm_ucast_mgr_t *) dfsssp_ctx->p_mgr;
 		srcdest2vl_table = (vltable_t *) (dfsssp_ctx->srcdest2vl_table);
+	}
 	else
 		return hint_for_default_sl;