[PATCH 4.17 006/324] RDMA/qedr: Fix NULL pointer dereference when running over iWARP without RDMA-CM

From: Greg Kroah-Hartman
Date: Thu Aug 23 2018 - 04:39:23 EST


4.17-stable review patch. If anyone has any objections, please let me know.

------------------

From: "Kalderon, Michal" <Michal.Kalderon@xxxxxxxxxx>

[ Upstream commit 425cf5c1350a98b81f3ddda160b99c3be613a213 ]

Some RoCE specific code in qedr_modify_qp was run over an iWARP device
when running perftest benchmarks without the -R option.

The commit 3e44e0ee0893 ("IB/providers: Avoid null netdev check for RoCE")
exposed this. Dropping the check for NULL pointer on ndev in
qedr_modify_qp lead to a null pointer dereference when running over
iWARP. Before the code would identify ndev as being NULL and return an
error.

Fixes: 3e44e0ee0893 ("IB/providers: Avoid null netdev check for RoCE")
Signed-off-by: Ariel Elior <Ariel.Elior@xxxxxxxxxx>
Signed-off-by: Michal Kalderon <Michal.Kalderon@xxxxxxxxxx>
Reviewed-by: Parav Pandit <parav@xxxxxxxxxxxx>
Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxxxx>
Signed-off-by: Sasha Levin <alexander.levin@xxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
drivers/infiniband/hw/qedr/verbs.c | 3 +++
1 file changed, 3 insertions(+)

--- a/drivers/infiniband/hw/qedr/verbs.c
+++ b/drivers/infiniband/hw/qedr/verbs.c
@@ -1957,6 +1957,9 @@ int qedr_modify_qp(struct ib_qp *ibqp, s
}

if (attr_mask & (IB_QP_AV | IB_QP_PATH_MTU)) {
+ if (rdma_protocol_iwarp(&dev->ibdev, 1))
+ return -EINVAL;
+
if (attr_mask & IB_QP_PATH_MTU) {
if (attr->path_mtu < IB_MTU_256 ||
attr->path_mtu > IB_MTU_4096) {