Skip to contentSkip to conversation

opensm: Fixed pointer validity check in report_torus_changes()

PATCH In review Alex Netes 2 participants 2 messages Mar 7, 2011 1 message not in the archive InfiniBand

lore
Share & tools
lore

Alex Netes

author
#0 lore raw

PATCH 1/1 opensm: Fixed pointer validity check in report_torus_changes()

struct torus *nt should be checked for validity before getting assignments.

---
 opensm/osm_torus.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
opensm/osm_torus.c +7 -3
index add3cf9..7a2c252 100644
@@ -7423,13 +7423,17 @@ void report_torus_changes(struct torus *nt, struct torus *ot)
 {
 	unsigned cnt = 0;
 	unsigned i, j, k;
-	unsigned x_sz = nt->x_sz;
-	unsigned y_sz = nt->y_sz;
-	unsigned z_sz = nt->z_sz;
+	unsigned x_sz;
+	unsigned y_sz;
+	unsigned z_sz;
 
 	if (!(nt && ot))
 		return;
 
+	x_sz = nt->x_sz;
+	y_sz = nt->y_sz;
+	z_sz = nt->z_sz;
+
 	if (x_sz != ot->x_sz) {
 		cnt++;
 		OSM_LOG(&nt->osm->log, OSM_LOG_INFO,
Signature · 6 lines
1.7.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
In reply to a message not in the archive

Hi Alex,

Quoted 12 lines · Alex Netes

struct torus *nt should be checked for validity before getting assignments.

---
 opensm/osm_torus.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
opensm/osm_torus.c +0 -0
index add3cf9..7a2c252 100644

opensm/osm_torus.c void report_torus_changes(struct torus *nt, struct torus *ot) · line 7428

Quoted 9 lines
opensm/osm_torus.c +3 -3
@@ -7423,13 +7423,17 @@ void report_torus_changes(struct torus *nt, struct torus *ot)
 {
 	unsigned cnt = 0;
 	unsigned i, j, k;
-	unsigned x_sz = nt->x_sz;
-	unsigned y_sz = nt->y_sz;
-	unsigned z_sz = nt->z_sz;
+	unsigned x_sz;
+	unsigned y_sz;
+	unsigned z_sz;

Actually, nt is guaranteed to be non-NULL; check the only caller (torus_build_lfts()).

opensm/osm_torus.c void report_torus_changes(struct torus *nt, struct torus *ot) · line 7431

Quoted 3 lines
opensm/osm_torus.c +0 -0
 	if (!(nt && ot))
 		return;

This check for nt is redundant, I think. Only ot has any possibility of being NULL.

-- Jim

opensm/osm_torus.c void report_torus_changes(struct torus *nt, struct torus *ot) · line 7439

Quoted 8 lines
opensm/osm_torus.c +4 -0
+	x_sz = nt->x_sz;
+	y_sz = nt->y_sz;
+	z_sz = nt->z_sz;
+
 	if (x_sz != ot->x_sz) {
 		cnt++;
 		OSM_LOG(&nt->osm->log, OSM_LOG_INFO,

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