[openib-general] [PATCH] mthca: uninitialized variable

Michael S. Tsirkin mst at mellanox.co.il
Thu Jan 12 01:14:18 PST 2006


mthca was using sqp->ud_header.grh_present before it was initialized
by mthca_read_ah. Further, header->grh_present is set by ib_ud_header_init.

Signed-off-by: Michael S. Tsirkin <mst at mellanox.co.il>

Index: linux-2.6.14/drivers/infiniband/hw/mthca/mthca_qp.c
===================================================================
--- linux-2.6.14.orig/drivers/infiniband/hw/mthca/mthca_qp.c	2006-01-11 15:40:20.000000000 +0200
+++ linux-2.6.14/drivers/infiniband/hw/mthca/mthca_qp.c	2006-01-11 19:35:58.000000000 +0200
@@ -1432,7 +1432,7 @@ static int build_mlx_header(struct mthca
 	u16 pkey;
 
 	ib_ud_header_init(256, /* assume a MAD */
-			  sqp->ud_header.grh_present,
+			  mthca_ah_grh_present(to_mah(wr->wr.ud.ah)),
 			  &sqp->ud_header);
 
 	err = mthca_read_ah(dev, to_mah(wr->wr.ud.ah), &sqp->ud_header);
Index: linux-2.6.14/drivers/infiniband/hw/mthca/mthca_av.c
===================================================================
--- linux-2.6.14.orig/drivers/infiniband/hw/mthca/mthca_av.c	2005-12-23 08:02:56.000000000 +0200
+++ linux-2.6.14/drivers/infiniband/hw/mthca/mthca_av.c	2006-01-11 19:34:48.000000000 +0200
@@ -161,6 +161,11 @@ int mthca_destroy_ah(struct mthca_dev *d
 	return 0;
 }
 
+int mthca_ah_grh_present(struct mthca_ah *ah)
+{
+	return !!(ah->av->g_slid & 0x80);
+}
+
 int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah,
 		  struct ib_ud_header *header)
 {
@@ -170,8 +175,7 @@ int mthca_read_ah(struct mthca_dev *dev,
 	header->lrh.service_level   = be32_to_cpu(ah->av->sl_tclass_flowlabel) >> 28;
 	header->lrh.destination_lid = ah->av->dlid;
 	header->lrh.source_lid      = cpu_to_be16(ah->av->g_slid & 0x7f);
-	if (ah->av->g_slid & 0x80) {
-		header->grh_present = 1;
+	if (mthca_ah_grh_present(ah)) {
 		header->grh.traffic_class =
 			(be32_to_cpu(ah->av->sl_tclass_flowlabel) >> 20) & 0xff;
 		header->grh.flow_label    =
@@ -182,8 +186,6 @@ int mthca_read_ah(struct mthca_dev *dev,
 				  &header->grh.source_gid);
 		memcpy(header->grh.destination_gid.raw,
 		       ah->av->dgid, 16);
-	} else {
-		header->grh_present = 0;
 	}
 
 	return 0;

-- 
MST



More information about the general mailing list