[PATCH] opensm: Fixed pointer validity check in report_torus_changes()

2011-03-07 Thread Alex Netes
struct torus *nt should be checked for validity before getting assignments.

Signed-off-by: Alex Netes ale...@mellanox.com
---
 opensm/osm_torus.c |   10 +++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/opensm/osm_torus.c b/opensm/osm_torus.c
index add3cf9..7a2c252 100644
--- a/opensm/osm_torus.c
+++ b/opensm/osm_torus.c
@@ -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,
-- 
1.7.3.4

--
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


Re: [PATCH] opensm: Fixed pointer validity check in report_torus_changes()

2011-03-07 Thread Jim Schutt

Hi Alex,

On Mon, 2011-03-07 at 02:59 -0700, Alex Netes wrote:
 struct torus *nt should be checked for validity before getting assignments.
 
 Signed-off-by: Alex Netes ale...@mellanox.com
 ---
  opensm/osm_torus.c |   10 +++---
  1 files changed, 7 insertions(+), 3 deletions(-)
 
 diff --git a/opensm/osm_torus.c b/opensm/osm_torus.c
 index add3cf9..7a2c252 100644
 --- a/opensm/osm_torus.c
 +++ b/opensm/osm_torus.c
 @@ -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()).

  
   if (!(nt  ot))
   return;

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

-- Jim

  
 + 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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html