From: sashiko-bot@kernel.org
To: "Prathamesh Deshpande" <prathameshdeshpande7@gmail.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH rdma] RDMA/mlx5: Cancel software CQ notifications before teardown
Date: Thu, 08 Oct 2026 14:24:54 +0000 [thread overview]
Message-ID: <sashiko-outbox-164281@kernel.org> (raw)
In-Reply-To: <20261008141209.6923-1-prathameshdeshpande7@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] rdma/mlx5: missing wc_list drain in mlx5_ib_pre_destroy_cq() causes leak
--
commit bb2bb35d84abe8b8d9f71ac658dfcd1b34acddcb
Author: Prathamesh Deshpande <prathameshdeshpande7@gmail.com>
RDMA/mlx5: Cancel software CQ notifications before teardown
This commit cancels notify_work in the pre-destroy callback to prevent queued
or running work from accessing a freed CQ or restarting polling after the CQ
is drained. User CQs are skipped because they do not initialize this work
item.
> diff --git a/drivers/infiniband/hw/mlx5/cq.c b/drivers/infiniband/hw/mlx5/cq.c
> index 072b77a2c8a6c..7495e20c3dec9 100644
> --- a/drivers/infiniband/hw/mlx5/cq.c
> +++ b/drivers/infiniband/hw/mlx5/cq.c
> @@ -1117,6 +1117,9 @@ int mlx5_ib_pre_destroy_cq(struct ib_cq *cq)
> struct mlx5_ib_dev *dev = to_mdev(cq->device);
> struct mlx5_ib_cq *mcq = to_mcq(cq);
>
> + if (!cq->uobject)
> + cancel_work_sync(&mcq->notify_work);
> +
[Severity: Medium]
Does this code cause a memory leak regression by leaving dynamically allocated
elements in mcq->wc_list undrained?
When mlx5_ib_generate_wc() generates software completions, it dynamically
allocates memory for them and queues them to the wc_list:
mlx5_ib_generate_wc() {
...
soft_wc = kmalloc_obj(*soft_wc, GFP_ATOMIC);
...
list_add_tail(&soft_wc->list, &cq->wc_list);
...
}
If the CQ is destroyed before these completions are polled,
mlx5_ib_pre_destroy_cq() correctly stops the workqueue to prevent
use-after-free, but it fails to drain mcq->wc_list.
Since the work queue is no longer running to consume these elements, they
will be leaked when the CQ is freed.
> return mlx5_core_destroy_cq(dev->mdev, &mcq->mcq);
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261008141209.6923-1-prathameshdeshpande7@gmail.com?part=1
prev parent reply other threads:[~2026-10-08 14:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-08 14:12 [PATCH rdma] RDMA/mlx5: Cancel software CQ notifications before teardown Prathamesh Deshpande
2026-10-08 14:24 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-164281@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=prathameshdeshpande7@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox