diff mbox series

qedr/verbs: Add pd pointer null check

Message ID 20240927191818.3576242-1-shum.sdl@nppct.ru (mailing list archive)
State Deferred
Headers show
Series qedr/verbs: Add pd pointer null check | expand

Commit Message

Andrey Shumilin Sept. 27, 2024, 7:18 p.m. UTC
It is possible that a null pointer will be passed
to the qedr_set_common_qp_params function.
The patch adds a pointer check before dereferencing.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Andrey Shumilin <shum.sdl@nppct.ru>

---
 drivers/infiniband/hw/qedr/verbs.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c
index 511c95bb3d01..09bb7fbe2bba 100644
--- a/drivers/infiniband/hw/qedr/verbs.c
+++ b/drivers/infiniband/hw/qedr/verbs.c
@@ -2270,6 +2270,11 @@  struct ib_qp *qedr_create_qp(struct ib_pd *ibpd,
 		return ERR_PTR(-ENOMEM);
 	}
 
+	if (!pd) {
+		DP_ERR(dev, "create qp: pd is NULL\n");
+		return ERR_PTR(-EINVAL);
+	}
+
 	qedr_set_common_qp_params(dev, qp, pd, attrs);
 
 	if (attrs->qp_type == IB_QPT_GSI) {