From: Jack Morgenstein Date: Thu, 3 Nov 2005 22:58:33 +0000 (-0800) Subject: [IB] mthca: check P_Key index in modify QP X-Git-Tag: v2.6.15-rc1~726^2~2^2 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=d09e32764176b61c4afee9fd5e7fe04713bfa56f;p=linux-2.6-omap-h63xx.git [IB] mthca: check P_Key index in modify QP Make sure that the P_Key index passed into mthca_modify_qp() is within the device's P_Key table. Signed-off-by: Jack Morgenstein Signed-off-by: Roland Dreier --- diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c index 62ff091505d..8b0b93565a2 100644 --- a/drivers/infiniband/hw/mthca/mthca_qp.c +++ b/drivers/infiniband/hw/mthca/mthca_qp.c @@ -582,6 +582,13 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask) return -EINVAL; } + if ((attr_mask & IB_QP_PKEY_INDEX) && + attr->pkey_index >= dev->limits.pkey_table_len) { + mthca_dbg(dev, "PKey index (%u) too large. max is %d\n", + attr->pkey_index,dev->limits.pkey_table_len-1); + return -EINVAL; + } + mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); if (IS_ERR(mailbox)) return PTR_ERR(mailbox);