From: Jonathan Cameron <jic23@kernel.org>
To: Junjie Cao <junjie.cao@intel.com>
Cc: qemu-devel@nongnu.org, linux-cxl@vger.kernel.org, qemu-stable@nongnu.org
Subject: Re: [PATCH 1/6] hw/cxl: fix timer leak in cxl_destroy_cci()
Date: Tue, 21 Jul 2026 02:03:20 +0100 [thread overview]
Message-ID: <20260721020320.4545bd3a@jic23-huawei> (raw)
In-Reply-To: <20260626062149.1844334-2-junjie.cao@intel.com>
On Fri, 26 Jun 2026 14:21:44 +0800
Junjie Cao <junjie.cao@intel.com> wrote:
> cxl_init_cci() allocates a QEMUTimer via timer_new_ms() but
> cxl_destroy_cci() never frees it. This leaks a timer object on every
> device exit path and, more critically, on every device reset cycle since
> the secondary CCIs (vdm_fm_owned_ld_mctp_cci, ld0_cci) are destroyed
> and re-initialized each time ct3d_reset() runs.
>
> Free the timer with timer_free(), which cancels any pending expiry via
> timer_del() internally and tolerates a NULL pointer, then clear the
> field so that a repeated timer_free() on the same CCI is a safe no-op.
> (The function as a whole is not idempotent: it also calls
> qemu_mutex_destroy(), which asserts on an already-destroyed mutex.
> Callers must not invoke cxl_destroy_cci() twice; the .initialized guard
> added in the next patch enforces that.)
>
> Fixes: 98cbac128f1c ("hw/cxl: Support aborting background commands")
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Junjie Cao <junjie.cao@intel.com>
Hi. Sorry for delay on catching up with these.
One minor thing inline - otherwise looks good to me.
Jonathan
> ---
> hw/cxl/cxl-mailbox-utils.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c
> index 20e0b7e476..18a455e89c 100644
> --- a/hw/cxl/cxl-mailbox-utils.c
> +++ b/hw/cxl/cxl-mailbox-utils.c
> @@ -4770,6 +4770,8 @@ void cxl_init_cci(CXLCCI *cci, size_t payload_max)
>
> void cxl_destroy_cci(CXLCCI *cci)
> {
> + timer_free(cci->bg.timer);
> + cci->bg.timer = NULL;
Can we do this in reverse of the cxl_init_cci() ordering? That would
put these after the qemu_mutex_destroy()
> qemu_mutex_destroy(&cci->bg.lock);
> cci->initialized = false;
> }
next prev parent reply other threads:[~2026-07-21 1:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 6:21 [PATCH 0/6] hw/cxl: fix Type-3 device reset resource leaks and convert to three-phase Junjie Cao
2026-06-26 6:21 ` [PATCH 1/6] hw/cxl: fix timer leak in cxl_destroy_cci() Junjie Cao
2026-07-21 1:03 ` Jonathan Cameron [this message]
2026-06-26 6:21 ` [PATCH 2/6] hw/cxl: destroy primary CCI before re-initialization on reset Junjie Cao
2026-06-26 6:21 ` [PATCH 3/6] hw/cxl: convert cxl-type3 to three-phase reset Junjie Cao
2026-06-26 6:21 ` [PATCH 4/6] hw/cxl: free in-flight sanitize state on reset Junjie Cao
2026-06-26 6:21 ` [PATCH 5/6] hw/cxl: clear event logs, scan media and interrupt policy " Junjie Cao
2026-06-26 6:21 ` [PATCH 6/6] hw/cxl: clear poison lists and feature transfer state " Junjie Cao
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=20260721020320.4545bd3a@jic23-huawei \
--to=jic23@kernel.org \
--cc=junjie.cao@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
/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