[openib-general] [PATCH] mthca: check port validity in modify_qp

Jack Morgenstein jackm at mellanox.co.il
Sun Jan 1 02:49:52 PST 2006


Modify_qp should check that the physical port number provided is a legal value.

Signed-off-by: Jack Morgenstein <jackm at mellanox.co.il>

Index: linux-kernel/drivers/infiniband/hw/mthca/mthca_qp.c
===================================================================
--- linux-kernel/drivers/infiniband/hw/mthca/mthca_qp.c	(revision 4666)
+++ linux-kernel/drivers/infiniband/hw/mthca/mthca_qp.c	(working copy)
@@ -619,6 +619,12 @@ int mthca_modify_qp(struct ib_qp *ibqp, 
 		return -EINVAL;
 	}
 
+	if ((attr_mask & IB_QP_PORT) &&
+	    (attr->port_num == 0 || attr->port_num > dev->limits.num_ports)) {
+		mthca_dbg(dev, "Port number (%u) is invalid\n", attr->port_num);
+		return -EINVAL;
+	}
+
 	if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC &&
 	    attr->max_rd_atomic > dev->limits.max_qp_init_rdma) {
 		mthca_dbg(dev, "Max rdma_atomic as initiator %u too large (max is %d)\n",



More information about the general mailing list