Skip to content

Commit 91724c1

Browse files
bharatpotnurijgunthorpe
authored andcommitted
RDMA/iw_cxgb4: fix SRQ access from dump_qp()
dump_qp() is wrongly trying to dump SRQ structures as QP when SRQ is used by the application. This patch matches the QPID before dumping them. Also removes unwanted SRQ id addition to QP id xarray. Fixes: 2f43129 ("cxgb4: Convert qpidr to XArray") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Rahul Kundu <[email protected]> Signed-off-by: Potnuri Bharat Teja <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 34b3be1 commit 91724c1

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

drivers/infiniband/hw/cxgb4/device.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,13 @@ static void set_ep_sin6_addrs(struct c4iw_ep *ep,
242242
}
243243
}
244244

245-
static int dump_qp(struct c4iw_qp *qp, struct c4iw_debugfs_data *qpd)
245+
static int dump_qp(unsigned long id, struct c4iw_qp *qp,
246+
struct c4iw_debugfs_data *qpd)
246247
{
247248
int space;
248249
int cc;
250+
if (id != qp->wq.sq.qid)
251+
return 0;
249252

250253
space = qpd->bufsize - qpd->pos - 1;
251254
if (space == 0)
@@ -350,7 +353,7 @@ static int qp_open(struct inode *inode, struct file *file)
350353

351354
xa_lock_irq(&qpd->devp->qps);
352355
xa_for_each(&qpd->devp->qps, index, qp)
353-
dump_qp(qp, qpd);
356+
dump_qp(index, qp, qpd);
354357
xa_unlock_irq(&qpd->devp->qps);
355358

356359
qpd->buf[qpd->pos++] = 0;

drivers/infiniband/hw/cxgb4/qp.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2737,15 +2737,11 @@ int c4iw_create_srq(struct ib_srq *ib_srq, struct ib_srq_init_attr *attrs,
27372737
if (CHELSIO_CHIP_VERSION(rhp->rdev.lldi.adapter_type) > CHELSIO_T6)
27382738
srq->flags = T4_SRQ_LIMIT_SUPPORT;
27392739

2740-
ret = xa_insert_irq(&rhp->qps, srq->wq.qid, srq, GFP_KERNEL);
2741-
if (ret)
2742-
goto err_free_queue;
2743-
27442740
if (udata) {
27452741
srq_key_mm = kmalloc(sizeof(*srq_key_mm), GFP_KERNEL);
27462742
if (!srq_key_mm) {
27472743
ret = -ENOMEM;
2748-
goto err_remove_handle;
2744+
goto err_free_queue;
27492745
}
27502746
srq_db_key_mm = kmalloc(sizeof(*srq_db_key_mm), GFP_KERNEL);
27512747
if (!srq_db_key_mm) {
@@ -2789,8 +2785,6 @@ int c4iw_create_srq(struct ib_srq *ib_srq, struct ib_srq_init_attr *attrs,
27892785
kfree(srq_db_key_mm);
27902786
err_free_srq_key_mm:
27912787
kfree(srq_key_mm);
2792-
err_remove_handle:
2793-
xa_erase_irq(&rhp->qps, srq->wq.qid);
27942788
err_free_queue:
27952789
free_srq_queue(srq, ucontext ? &ucontext->uctx : &rhp->rdev.uctx,
27962790
srq->wr_waitp);
@@ -2813,8 +2807,6 @@ void c4iw_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata)
28132807
rhp = srq->rhp;
28142808

28152809
pr_debug("%s id %d\n", __func__, srq->wq.qid);
2816-
2817-
xa_erase_irq(&rhp->qps, srq->wq.qid);
28182810
ucontext = rdma_udata_to_drv_context(udata, struct c4iw_ucontext,
28192811
ibucontext);
28202812
free_srq_queue(srq, ucontext ? &ucontext->uctx : &rhp->rdev.uctx,

0 commit comments

Comments
 (0)