Otherwise 1) presence of the wrong switches is checked; and 2) the y-loop
in good_xy_ring() can segfault on an out-of-bounds switch array x index.

Signed-off-by: Jim Schutt <jasc...@sandia.gov>
---
 opensm/opensm/osm_ucast_torus.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/opensm/opensm/osm_ucast_torus.c b/opensm/opensm/osm_ucast_torus.c
index e2eb324..728e56c 100644
--- a/opensm/opensm/osm_ucast_torus.c
+++ b/opensm/opensm/osm_ucast_torus.c
@@ -8751,22 +8751,23 @@ ib_api_status_t torus_mcast_stree(void *context, 
osm_mgrp_box_t *mgb)
 }
 
 static
-bool good_xy_ring(struct torus *t, int x, int y, int z)
+bool good_xy_ring(struct torus *t, const int x, const int y, const int z)
 {
        struct t_switch ****sw = t->sw;
        bool good_ring = true;
+       int x_tst, y_tst;
 
-       for (x = 0; x < t->x_sz && good_ring; x++)
-               good_ring = sw[x][y][z];
+       for (x_tst = 0; x_tst < t->x_sz && good_ring; x_tst++)
+               good_ring = sw[x_tst][y][z];
 
-       for (y = 0; y < t->y_sz && good_ring; y++)
-               good_ring = sw[x][y][z];
+       for (y_tst = 0; y_tst < t->y_sz && good_ring; y_tst++)
+               good_ring = sw[x][y_tst][z];
 
        return good_ring;
 }
 
 static
-struct t_switch *find_plane_mid(struct torus *t, int z)
+struct t_switch *find_plane_mid(struct torus *t, const int z)
 {
        int x, dx, xm = t->x_sz / 2;
        int y, dy, ym = t->y_sz / 2;
-- 
1.5.6.GIT


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

Reply via email to