From: Parav Pandit <parav@mellanox.com>
Date: Tue, 28 Aug 2018 14:45:28 +0300
Subject: RDMA/core: Fail early if unsupported QP is provided
Patch-mainline: v4.20-rc1
Git-commit: 798bba01b44b0ddf8cd6e542635b37cc9a9b739c
References: bsc#1103992 FATE#326009
When requested QP type is not supported for a {device, port}, return the
error right away before validating all parameters during mad agent
registration time.
Signed-off-by: Parav Pandit <parav@mellanox.com>
Reviewed-by: Daniel Jurgens <danielj@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Acked-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
drivers/infiniband/core/mad.c | 4 ++++
1 file changed, 4 insertions(+)
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -214,6 +214,10 @@ struct ib_mad_agent *ib_register_mad_age
int ret2, qpn;
u8 mgmt_class, vclass;
+ if ((qp_type == IB_QPT_SMI && !rdma_cap_ib_smi(device, port_num)) ||
+ (qp_type == IB_QPT_GSI && !rdma_cap_ib_cm(device, port_num)))
+ return ERR_PTR(-EPROTONOSUPPORT);
+
/* Validate parameters */
qpn = get_spl_qp_index(qp_type);
if (qpn == -1) {