From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH 2/2] qemu/timer: Sanity check timer_list in timer_init_full()
Date: Sat, 25 Jan 2025 19:24:25 +0100 [thread overview]
Message-ID: <20250125182425.59708-3-philmd@linaro.org> (raw)
In-Reply-To: <20250125182425.59708-1-philmd@linaro.org>
Ensure we are not re-initializing a QEMUTimer already added
to an active list. timer_init*() functions expect either
a recently created and zeroed QEMUTimer, or one previously
free'd with timer_free().
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/qemu/timer.h | 2 +-
util/qemu-timer.c | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/qemu/timer.h b/include/qemu/timer.h
index abd2204f3be..4717693f950 100644
--- a/include/qemu/timer.h
+++ b/include/qemu/timer.h
@@ -407,7 +407,7 @@ int64_t timerlistgroup_deadline_ns(QEMUTimerListGroup *tlg);
* (or default timer list group, if NULL).
* The caller is responsible for allocating the memory.
*
- * You need not call an explicit deinit call. Simply make
+ * You need not call an explicit timer_deinit() call. Simply make
* sure it is not on a list with timer_del.
*/
void timer_init_full(QEMUTimer *ts,
diff --git a/util/qemu-timer.c b/util/qemu-timer.c
index 0e8a453eaa1..058cae6e487 100644
--- a/util/qemu-timer.c
+++ b/util/qemu-timer.c
@@ -354,6 +354,7 @@ void timer_init_full(QEMUTimer *ts,
if (!timer_list_group) {
timer_list_group = &main_loop_tlg;
}
+ assert(ts->timer_list == NULL);
ts->timer_list = timer_list_group->tl[type];
ts->cb = cb;
ts->opaque = opaque;
--
2.47.1
next prev parent reply other threads:[~2025-01-25 18:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-25 18:24 [PATCH 0/2] qemu/timer: Clarify QEMUTimer new/free API Philippe Mathieu-Daudé
2025-01-25 18:24 ` [PATCH 1/2] qemu/timer: Clarify timer_new*() must be freed with timer_free() Philippe Mathieu-Daudé
2025-02-06 10:39 ` Daniel P. Berrangé
2025-01-25 18:24 ` Philippe Mathieu-Daudé [this message]
2025-02-06 10:40 ` [PATCH 2/2] qemu/timer: Sanity check timer_list in timer_init_full() Daniel P. Berrangé
2025-02-09 9:37 ` Michael Tokarev
2025-02-09 9:41 ` Michael Tokarev
2025-02-09 17:41 ` Philippe Mathieu-Daudé
2025-02-04 21:44 ` [PATCH 0/2] qemu/timer: Clarify QEMUTimer new/free API Philippe Mathieu-Daudé
2025-02-06 9:44 ` Philippe Mathieu-Daudé
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=20250125182425.59708-3-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.