From nobody Sat May 10 01:11:21 2025
Delivered-To: importer@patchew.org
Authentication-Results: mx.zohomail.com;
	dkim=pass;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=pass(p=none dis=none)  header.from=linaro.org
ARC-Seal: i=1; a=rsa-sha256; t=1737829504; cv=none;
	d=zohomail.com; s=zohoarc;
	b=MDaTSYLpxvlPJzfARbTsuQhTDxLSzN6hMiKbziOXTMABQCbIBhvtIcDE9RjvgVIqNsSF8O5Dj1be//JL1cBmflx3FzvESBayRnrmq7ZxF9xqepCDdSatDjezn7REBfEPcK+E+8SZcSbl58nM6TrnkVGvYDBFU4HyoV99QkuUJ40=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;
 s=zohoarc;
	t=1737829504;
 h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To;
	bh=BvRb+A+szaUASQC+0C2N8r34T+ZA8fbAScI9edWRsk8=;
	b=ZbcDg8/bVYc+fBKo6Da/jNXEoT+hIB4ow1Ub8SqWzleht85J/6Hnj98qU43u+DY4la7rx8fwtmpaHGviMScF3VeafWxMN5wDW7jcb6IMHX20EUvCe/V6k64JpFllQf86p0HeL3vCg6XpKg/l6Prz2/uGQ0TOD3cV6F41ii7jjOQ=
ARC-Authentication-Results: i=1; mx.zohomail.com;
	dkim=pass;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org;
	dmarc=pass header.from=<philmd@linaro.org> (p=none dis=none)
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 1737829504110194.64493007647422;
 Sat, 25 Jan 2025 10:25:04 -0800 (PST)
Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces@nongnu.org>)
	id 1tbkpm-0007ec-P1; Sat, 25 Jan 2025 13:24:42 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <philmd@linaro.org>) id 1tbkpl-0007eB-Ao
 for qemu-devel@nongnu.org; Sat, 25 Jan 2025 13:24:41 -0500
Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <philmd@linaro.org>) id 1tbkpj-0005nt-ON
 for qemu-devel@nongnu.org; Sat, 25 Jan 2025 13:24:41 -0500
Received: by mail-wr1-x436.google.com with SMTP id
 ffacd0b85a97d-3862b40a6e0so2264930f8f.0
 for <qemu-devel@nongnu.org>; Sat, 25 Jan 2025 10:24:39 -0800 (PST)
Received: from localhost.localdomain (88-187-86-199.subs.proxad.net.
 [88.187.86.199]) by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-38c2a1c42b4sm6223869f8f.99.2025.01.25.10.24.36
 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
 Sat, 25 Jan 2025 10:24:37 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=linaro.org; s=google; t=1737829478; x=1738434278; darn=nongnu.org;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=BvRb+A+szaUASQC+0C2N8r34T+ZA8fbAScI9edWRsk8=;
 b=qjm+tDBc2XTg9I30LGfqkkRYUXX9OnzjfJ/xtOfVr2rFfM/RE7P9b19Iuh/NKzsp/t
 cekXKQRRftcpVX6/j13VygfQvN1GuOVp3n4jevFVDk4eD2kw/R4llI7dcYFwDyk7EuYM
 x+jvUpZXPShBJ58llzKbPm25SRFRWwNKNdNjoMk15v0Ooz6FXEtOX2DimV72go3eOpwI
 lndpjkEKRlgTJYmshwhlD0NQlq1b2IRICHPcaw2dnfDqs81bnyrek5Zyee/DR9axb5f7
 7VYHMbY3hqaG61JScDXpTHT8M/Q4KokUAg5/tlKtTDME90ZREKuEseUk+TKuXhGQpQnW
 /OBQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1737829478; x=1738434278;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=BvRb+A+szaUASQC+0C2N8r34T+ZA8fbAScI9edWRsk8=;
 b=n6mqg5blLQ3wzz/iSYu8avcI50aYVeQESMwAc5giosBfPbkKzO2gTkSPDjTfpNWJ1j
 MT7MZ8vMx91ykZbqqyncCtt2E4jgYQeKS07jPQfk5OBB8nnrbZnRdDJKEtDZMrhA6Xmi
 RsWXAzhDrNRtllUT6iWDOlpZ28ra65b6ZPKltv41x/e9/05ectoXCLELIKUVKupi3XUS
 5m5/dvgoV+mcivZc/d1GrfAy7y2CFB8A3R9XAcxrx1RJUgL1T6JC8o+uN4a8Aft3MDUs
 iG027K11sL6UM47zO2lRzlYM/KXXjMarSbGVmmitF1hdWcoTUzp3AGVrzKXTGmbholI/
 gTHg==
X-Gm-Message-State: AOJu0YwftMhG0EfZXknJp4vFnxhz0qV1xHVTO7Xl2L0f6s9EAJ+XtELz
 /evUe+Vc/P5S3U9WdLRlOPnsAZTTtK5XIjIaIz65T9QYHsjzRrNKXgMVXAXgVWBddDkJVmdVyKk
 YI/I=
X-Gm-Gg: ASbGncsgSyIQh5g4e0tDl2yR47RPFbheM7BcBB+E4S1Gviuuu09ZuzdmPA9S/QUFR1K
 QhyZ8Jz+8fXvge08QRq9zr/4UImQeypXG3LZ38+E00lSGC+7TmMIvslSszlqg69jBZ5QqFyvi7L
 RXqRuuyPgoTeGSArXelGb6zGWjXXZHq9pGgK2OKvz7/f0Gl1Vq826nd757xmmRbiQmLqwsH2PhA
 LNXl4+bVBTJJ7wD3gTYWEfjW6rlVA5sPHRr1ha6NUaCc/4Cl1hq38M0hQzjBUyWUp13ykTSaSRi
 e0Kdt+rhng/sptQrdwiuzpsXlGsiaJ/Pfnr4ljZllOK5EUbIXFvnW/6S8HWB
X-Google-Smtp-Source: 
 AGHT+IEG/e5B52a79+jtYsln2JUwLvWGeOYA0IM+FAgXXkx733f0iHdltm87kfPpIMKN5DYLkxxjiQ==
X-Received: by 2002:a05:6000:156c:b0:386:1cd3:8a05 with SMTP id
 ffacd0b85a97d-38bf57ce963mr35716064f8f.54.1737829477843;
 Sat, 25 Jan 2025 10:24:37 -0800 (PST)
From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
 Peter Maydell <peter.maydell@linaro.org>,
 =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= <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
Message-ID: <20250125182425.59708-3-philmd@linaro.org>
X-Mailer: git-send-email 2.47.1
In-Reply-To: <20250125182425.59708-1-philmd@linaro.org>
References: <20250125182425.59708-1-philmd@linaro.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17
 as permitted sender) client-ip=209.51.188.17;
 envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org;
 helo=lists.gnu.org;
Received-SPF: pass client-ip=2a00:1450:4864:20::436;
 envelope-from=philmd@linaro.org; helo=mail-wr1-x436.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org
X-ZohoMail-DKIM: pass (identity @linaro.org)
X-ZM-MESSAGEID: 1737829506267019000

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=C3=A9 <philmd@linaro.org>
Reviewed-by: Daniel P. Berrang=C3=A9 <berrange@redhat.com>
---
 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 =3D &main_loop_tlg;
     }
+    assert(ts->timer_list =3D=3D NULL);
     ts->timer_list =3D timer_list_group->tl[type];
     ts->cb =3D cb;
     ts->opaque =3D opaque;
--=20
2.47.1