diff mbox

opensm/osm_torus.c: In dump_torus, make sure switch is present before dumping

Message ID 20130204093600.GA13151@calypso.mtl.com (mailing list archive)
State Accepted
Delegated to: Hal Rosenstock
Headers show

Commit Message

Alex Netes Feb. 4, 2013, 9:36 a.m. UTC
Fix segmentation fault in osm_torus.c.

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
Signed-off-by: Alex Netes <alexne@mellanox.com>
---
 opensm/osm_torus.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

Jim Schutt Feb. 4, 2013, 9:56 p.m. UTC | #1
On 02/04/2013 02:36 AM, Alex Netes wrote:
> Fix segmentation fault in osm_torus.c.
> 
> Signed-off-by: Hal Rosenstock <hal@mellanox.com>
> Signed-off-by: Alex Netes <alexne@mellanox.com>

Acked-by: Jim Schutt <jaschut@sandia.gov>

--
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_torus.c b/opensm/osm_torus.c
index 1510233..e63cb40 100644
--- a/opensm/osm_torus.c
+++ b/opensm/osm_torus.c
@@ -7517,11 +7517,12 @@  void dump_torus(struct torus *t)
 	for (k = 0; k < z_sz; k++)
 		for (j = 0; j < y_sz; j++)
 			for (i = 0; i < x_sz; i++)
-				fprintf(file, "switch %u,%u,%u GUID 0x%04"
-					PRIx64 " (%s)\n",
-					i, j, k,
-					cl_ntoh64(t->sw[i][j][k]->n_id),
-					t->sw[i][j][k]->osm_switch->p_node->print_desc);
+				if (t->sw[i][j][k])
+					fprintf(file, "switch %u,%u,%u GUID 0x%04"
+						PRIx64 " (%s)\n",
+						i, j, k,
+						cl_ntoh64(t->sw[i][j][k]->n_id),
+						t->sw[i][j][k]->osm_switch->p_node->print_desc);
 	fclose(file);
 }