diff mbox series

[18/25] RDMA/core: Validate signature handover device cap

Message ID 1557236319-9986-19-git-send-email-maxg@mellanox.com (mailing list archive)
State Superseded
Headers show
Series Introduce new API for T10-PI offload | expand

Commit Message

Max Gurtovoy May 7, 2019, 1:38 p.m. UTC
Protect the case that a ULP tries to allocate a QP with signature
enabled flag while the LLD doesn't support this feature.

Signed-off-by: Max Gurtovoy <maxg@mellanox.com>
---
 drivers/infiniband/core/verbs.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 7397a20db000..e1dcbcc58e3e 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -1142,10 +1142,12 @@  struct ib_qp *ib_create_qp(struct ib_pd *pd,
 	struct ib_qp *qp;
 	int ret;
 
-	if (qp_init_attr->rwq_ind_tbl &&
+	if ((qp_init_attr->rwq_ind_tbl &&
 	    (qp_init_attr->recv_cq ||
 	    qp_init_attr->srq || qp_init_attr->cap.max_recv_wr ||
-	    qp_init_attr->cap.max_recv_sge))
+	    qp_init_attr->cap.max_recv_sge)) ||
+	    ((qp_init_attr->create_flags & IB_QP_CREATE_SIGNATURE_EN) &&
+	     !(device->attrs.device_cap_flags & IB_DEVICE_SIGNATURE_HANDOVER)))
 		return ERR_PTR(-EINVAL);
 
 	/*