From patchwork Sat Jan 25 18:24:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 859839 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:18c8:b0:385:e875:8a9e with SMTP id w8csp1364869wrq; Sat, 25 Jan 2025 10:25:04 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWY8gn55K/Jhqe1rbMKG/jaBqIdPkS5FEctrpZkFb52ml2BqG8lVJK6Tj1HVGzOg8yX6HUvJg==@linaro.org X-Google-Smtp-Source: AGHT+IE3XQhdg0eNd29yTYjsUCyr+X+CsA6N8XCndbP1scbZYYyHLjju8H8Zt08rDK5IOcGbKLNG X-Received: by 2002:a05:6214:2686:b0:6d4:24cf:aaa4 with SMTP id 6a1803df08f44-6e1b215accdmr496546806d6.17.1737829504033; Sat, 25 Jan 2025 10:25:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1737829504; cv=none; d=google.com; s=arc-20240605; b=j1dh7D2YPPVyY3WdsopeV5jv4DeTxQec21VhPJPt5I6SD6HajPLRgODf4JM+NdzRIe aeU4HzumTNYJSWufCTrj0M08D+gW16CuBkjhyyrtjAb4V6t8ypMGomVa4yMQ+M185d0m ofVUO+C1EDXme+H9Yn/t9lpr/8vfQnb384s8tQAfOJN+JKaxNiWiM+oxw+RgMVcxaZYp izINRftEybhGy7ZfCc2fJkvpvcJWyg3o7/4zkO0sUJWvosut6OIX3PqLCJPWMKiNCp0j Fb55ZcvAaODe2H2yMmN/V67rWe/JFRAEwVHBKr2G8JEiIhkIJtNuZA526UT64LJRpuNY 1Y6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BvRb+A+szaUASQC+0C2N8r34T+ZA8fbAScI9edWRsk8=; fh=E8pPKytCAx/6S3k8M8s9JG1YoDHuQ5x+hNFr7lEG7J0=; b=Eb0fHyTRs2J//bL6nDquOgrrv+2IbslaGYs6llFK636xukkLiIzjh5JKYrMTn+fMll qod3do71oySal+iUo1Rh2L7eWYE48x2wUVDlbPelXNVC4xU9Lbw5/Tr/j4uovDOO8cWK IBHhtjFvXWB9C6TWxDklgSphuBdQoyvSFXWdx/Z9CoaDLN7xFCQDpEpF5m4/bDlOcIcP h7p+OTxezi2TmpDkyEVJ8J8GxVyiGBnFSfoa5TaI7RrTMuk3InosPTsvCocc+tXvdLAB 8RR4pvq53SNJT78kdGsWZIjNS4ADiBqSl8x6VREDWhyDCVSkSPD6aJkI4PcDOslS/2ZB Um9A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qjm+tDBc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-46e6688a830si52273151cf.196.2025.01.25.10.25.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 25 Jan 2025 10:25:04 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qjm+tDBc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) 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 ) 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 ) 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 ; Sat, 25 Jan 2025 10:24:39 -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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= 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 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.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é --- 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;