Commit a568814a authored by Leon Romanovsky's avatar Leon Romanovsky Committed by Jason Gunthorpe

RDMA/siw: Properly check send and receive CQ pointers

The check for the NULL of pointer received from container_of() is
incorrect by definition as it points to some offset from NULL.

Change such check with proper NULL check of SIW QP attributes.

Fixes: 303ae1cd ("rdma/siw: application interface")
Link: https://lore.kernel.org/r/a7535a82925f6f4c1f062abaa294f3ae6e54bdd2.1620560310.git.leonro@nvidia.comSigned-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
Reviewed-by: default avatarBernard Metzler <bmt@zurich.ibm.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent 6efb943b
...@@ -300,7 +300,6 @@ struct ib_qp *siw_create_qp(struct ib_pd *pd, ...@@ -300,7 +300,6 @@ struct ib_qp *siw_create_qp(struct ib_pd *pd,
struct siw_ucontext *uctx = struct siw_ucontext *uctx =
rdma_udata_to_drv_context(udata, struct siw_ucontext, rdma_udata_to_drv_context(udata, struct siw_ucontext,
base_ucontext); base_ucontext);
struct siw_cq *scq = NULL, *rcq = NULL;
unsigned long flags; unsigned long flags;
int num_sqe, num_rqe, rv = 0; int num_sqe, num_rqe, rv = 0;
size_t length; size_t length;
...@@ -343,10 +342,8 @@ struct ib_qp *siw_create_qp(struct ib_pd *pd, ...@@ -343,10 +342,8 @@ struct ib_qp *siw_create_qp(struct ib_pd *pd,
rv = -EINVAL; rv = -EINVAL;
goto err_out; goto err_out;
} }
scq = to_siw_cq(attrs->send_cq);
rcq = to_siw_cq(attrs->recv_cq);
if (!scq || (!rcq && !attrs->srq)) { if (!attrs->send_cq || (!attrs->recv_cq && !attrs->srq)) {
siw_dbg(base_dev, "send CQ or receive CQ invalid\n"); siw_dbg(base_dev, "send CQ or receive CQ invalid\n");
rv = -EINVAL; rv = -EINVAL;
goto err_out; goto err_out;
...@@ -401,8 +398,8 @@ struct ib_qp *siw_create_qp(struct ib_pd *pd, ...@@ -401,8 +398,8 @@ struct ib_qp *siw_create_qp(struct ib_pd *pd,
} }
} }
qp->pd = pd; qp->pd = pd;
qp->scq = scq; qp->scq = to_siw_cq(attrs->send_cq);
qp->rcq = rcq; qp->rcq = to_siw_cq(attrs->recv_cq);
if (attrs->srq) { if (attrs->srq) {
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment