[ofa-general] [PATCH] opensm/libvendor/osm_vendor_mlx_sa.c: handling attribute offset of 0

Yevgeny Kliteynik kliteyn at dev.mellanox.co.il
Sun Aug 17 08:12:18 PDT 2008


Following patch f752a876edecfdac9e1d07bc0747a2c296eed230,
"set SA attribute offset to 0 when no records are returned"

Attribute offset of 0 caused the vendor to crash.

Signed-off-by: Yevgeny Kliteynik <kliteyn at dev.mellanox.co.il>
---
 opensm/libvendor/osm_vendor_mlx_sa.c |   30 ++++++++++++++++++------------
 1 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/opensm/libvendor/osm_vendor_mlx_sa.c b/opensm/libvendor/osm_vendor_mlx_sa.c
index efd04bd..d0da219 100644
--- a/opensm/libvendor/osm_vendor_mlx_sa.c
+++ b/opensm/libvendor/osm_vendor_mlx_sa.c
@@ -140,18 +140,24 @@ __osmv_sa_mad_rcv_cb(IN osm_madw_t * p_madw,
 #else
 			/* we used the offset value to calculate the number of
 			   records in here */
-			query_res.result_cnt = (uintn_t)
-			    ((p_madw->mad_size - IB_SA_MAD_HDR_SIZE) /
-			     ib_get_attr_size(p_sa_mad->attr_offset));
-			osm_log(p_bind->p_log, OSM_LOG_DEBUG,
-				"__osmv_sa_mad_rcv_cb: Count = %u = %u / %u (%u)\n",
-				query_res.result_cnt,
-				p_madw->mad_size - IB_SA_MAD_HDR_SIZE,
-				ib_get_attr_size(p_sa_mad->attr_offset),
-				(p_madw->mad_size -
-				 IB_SA_MAD_HDR_SIZE) %
-				ib_get_attr_size(p_sa_mad->attr_offset)
-			    );
+			if (ib_get_attr_size(p_sa_mad->attr_offset) == 0) {
+				query_res.result_cnt = 0;
+				osm_log(p_bind->p_log, OSM_LOG_DEBUG,
+					"__osmv_sa_mad_rcv_cb: Count = 0\n");
+			}
+			else {
+				query_res.result_cnt = (uintn_t)
+					((p_madw->mad_size - IB_SA_MAD_HDR_SIZE) /
+					 ib_get_attr_size(p_sa_mad->attr_offset));
+				osm_log(p_bind->p_log, OSM_LOG_DEBUG,
+					"__osmv_sa_mad_rcv_cb: "
+					"Count = %u = %zu / %u (%zu)\n",
+					query_res.result_cnt,
+					p_madw->mad_size - IB_SA_MAD_HDR_SIZE,
+					ib_get_attr_size(p_sa_mad->attr_offset),
+					(p_madw->mad_size - IB_SA_MAD_HDR_SIZE) %
+					ib_get_attr_size(p_sa_mad->attr_offset));
+			}
 #endif
 		}
 	}
-- 
1.5.1.4




More information about the general mailing list