From nobody Sun Sep 28 17:05:16 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=1756818745; cv=none; d=zohomail.com; s=zohoarc; b=m6I6Gpj/r+CQ/4/zqLPeo/kzigLrnw4PJHdcIxwjSjAhDu1isYqWFpHBmhBbwy9OE8tmLRaW90gcFHgqbJZs5V+vHoxe7zwM9+FOwaPAOtUA89zXTYXdwxVq8HzyY5bj18Jn7bfZr7zRBGKVR97cwt9dvdSrZoZ0iKNjht2iRow= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756818745; h=Content-Type:Content-Transfer-Encoding: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:Cc; bh=RM//SOSyMG1jcYS0Uj3ddE2XoaaYiQer2JjB+xASa4s=; b=lw+CEVS0uQUeX0s4ONNLdc0uS9oMEmM7osb+d/qB5AnyMcaO8JXXZ4WeqA+9KTckEZFE62yotCgRSscZDRKFqKnLkZdoz5XUC5BwwSWsD5rhaX92Cr4LTQifCmFvwzdJ4zRQwqeXQUJFXnDyY8zMbU0YHTEOSWFBKH5Y5umPTwA= 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= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1756818745366611.4732209825854; Tue, 2 Sep 2025 06:12:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1utQnx-0002cb-ER; Tue, 02 Sep 2025 09:12:09 -0400 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 1utQns-00024C-JP for qemu-devel@nongnu.org; Tue, 02 Sep 2025 09:12:04 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1utQnm-0004bm-SQ for qemu-devel@nongnu.org; Tue, 02 Sep 2025 09:12:04 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3cef6debedcso2433888f8f.3 for ; Tue, 02 Sep 2025 06:11:57 -0700 (PDT) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3d53fda847dsm10623228f8f.0.2025.09.02.06.11.54 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Sep 2025 06:11:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1756818715; x=1757423515; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=RM//SOSyMG1jcYS0Uj3ddE2XoaaYiQer2JjB+xASa4s=; b=WKaMEc+rS1oYZAR1DxvBsKk22+zk2/CUbnpTEVS+zDP+Dc+VU2DD14xFX8je1vD0zj CRy5bVBi+xgh8QSw7D9ekoS+RohQht6b0hjskEUFYdBlWQNar9fnA5DR7rRF6ke45X/w T/AOBLyUX48C581b4eYeqOd6sQ3KM6uB69Mu+2U8VwK+b0LqwuRgdbZVNhdEqnFQOb8l DGGjwRgBh2JOWRb8Z/AOwfEvpJPJRjEHFReNZKVC5kkDtMKBNUSrFeqfxps6LpGTw39i EkgdxYVunbsy5J8UePHNAXc+u6hhNJ7kWSjN/lwl6hn+pFeO++SgRxBz7M0tWIAE5flm fESA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756818715; x=1757423515; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RM//SOSyMG1jcYS0Uj3ddE2XoaaYiQer2JjB+xASa4s=; b=cw0OQ2Nw0z7sHgspXpB4VC0+n6gQoc2ioTNF6nUy+MXCiLd1jNvZrgF8xF2QIkB01r /o0ly6qY0z8169ygUQfxvP5aIc10Xo3eIwDBTu4eEI2WMie2JZpdDc1hGbDhFQo+yAP9 9HOndSCU/LMeZE0Gy02Qm8lV+vHJ/QzCzLsaGJfuI/JXYaRvyb0xhNyyshF3UqkA++uB Id437XEsfOAfCt4425YY8WTl111OUJhWLeTNclXNIoNXLinx2okBzH1ekjomBKJsgQ/P 18beAtcMywL79Oft8tW4Y9ZN2oxNJ5zCvivyxTodNUkMjQcImqOJ+/3jvh+E1LwlKgWa Nk6A== X-Gm-Message-State: AOJu0YwcK9gAmShdUtHMOV4kPjIZA15o6VmiOPr2RSU2tjR9SaifEY+e eDZenTi9ztS7F71tvuTViRw7gyn6IB3ua78M7JjyRfpdwr8CYO6+xoc3YHwcwe8ufvxkpww0fij 661IN X-Gm-Gg: ASbGncupN0xwqTYcTiq00LUwu63MGupWx4z4PlI53hREXh5aRNAkPZrePO2vslOlosU +JoGkts5eTh8iI5EG0AFOMPm1kuXO+UcIxEz3M08n3aNVSyje/foSpiLfUqqMB2ROG7+UGSU1T2 YWAxsxnwlZtl3s0iWDcFqEHHXqw3vkzUuvhesvIier2L+xfyAJRiwNeebGmX0L9xfew7FAzbgdf CXcV/DRONEu4ZzB5TbzotcROlop/cchPQ9a1KGwK2h9iOnb1rySyvk8kijqZgoOOSoL5PJhSst7 unkONS9gAIWEPhBcr8dJMUamQxK90I346uf29mDyvJbxfucgSbQC6pxTCrE2F6s3pDnvADc9Blw uHcJBcUM322AigMGghfKIRemhQmyj1ajqneGijlFTq6Q7JgGhBFD6aNLfugmQKdNf3/QwoRO0 X-Google-Smtp-Source: AGHT+IGn/QtRcRwvQpS0NGy0xyc9gtUZcOnYBTxRHUQsQ770bbSYnEvCseuTdtlMCTU6VtkpKMhf9A== X-Received: by 2002:a05:6000:25ca:b0:3cd:93c5:eabc with SMTP id ffacd0b85a97d-3d1dcb7627emr7293564f8f.18.1756818715176; Tue, 02 Sep 2025 06:11:55 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 21/39] hw/char/serial-pci-multi: Use qemu_init_irq_child() to avoid leak Date: Tue, 2 Sep 2025 15:09:58 +0200 Message-ID: <20250902131016.84968-22-philmd@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250902131016.84968-1-philmd@linaro.org> References: <20250902131016.84968-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::429; envelope-from=philmd@linaro.org; helo=mail-wr1-x429.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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1756818749209124100 From: Peter Maydell The serial-pci-multi device initializes an IRQ with qemu_init_irq() in its instance_init function; however it never calls qemu_free_irq(), so the init/deinit cycle has a memory leak, which ASAN catches in the device-introspect-test: Direct leak of 576 byte(s) in 6 object(s) allocated from: #0 0x626306ddade3 in malloc (/mnt/nvmedisk/linaro/qemu-from-laptop/qemu= /build/arm-asan/qem u-system-arm+0x21f1de3) (BuildId: 52ece17287eba2d68e5be980e1856cd1f6be932f) #1 0x7756ade79b09 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0= x62b09) (BuildId: 1 eb6131419edb83b2178b682829a6913cf682d75) #2 0x7756ade5b45a in g_hash_table_new_full (/lib/x86_64-linux-gnu/libgl= ib-2.0.so.0+0x4445a ) (BuildId: 1eb6131419edb83b2178b682829a6913cf682d75) #3 0x62630965da37 in object_initialize_with_type /mnt/nvmedisk/linaro/q= emu-from-laptop/qem u/build/arm-asan/../../qom/object.c:568:23 #4 0x62630965d440 in object_initialize /mnt/nvmedisk/linaro/qemu-from-l= aptop/qemu/build/ar m-asan/../../qom/object.c:578:5 #5 0x626309653eeb in qemu_init_irq /mnt/nvmedisk/linaro/qemu-from-lapto= p/qemu/build/arm-as an/../../hw/core/irq.c:48:5 #6 0x6263072370bb in multi_serial_init /mnt/nvmedisk/linaro/qemu-from-l= aptop/qemu/build/arm-asan/../../hw/char/serial-pci-multi.c:183:9 Use the new qemu_init_irq_child() function instead, so that the IRQ object is automatically unreffed when the serial-pci device is deinited. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-ID: <20250821154053.2417090-3-peter.maydell@linaro.org> [PMD: Use "irq[*]" as child property name] Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/char/serial-pci-multi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/char/serial-pci-multi.c b/hw/char/serial-pci-multi.c index 13df272691a..34f30fb70b8 100644 --- a/hw/char/serial-pci-multi.c +++ b/hw/char/serial-pci-multi.c @@ -180,7 +180,8 @@ static void multi_serial_init(Object *o) size_t i, nports =3D multi_serial_get_port_count(PCI_DEVICE_GET_CLASS(= dev)); =20 for (i =3D 0; i < nports; i++) { - qemu_init_irq(&pms->irqs[i], multi_serial_irq_mux, pms, i); + qemu_init_irq_child(o, "irq[*]", &pms->irqs[i], + multi_serial_irq_mux, pms, i); object_initialize_child(o, "serial[*]", &pms->state[i], TYPE_SERIA= L); } } --=20 2.51.0