From nobody Mon Feb 9 20:34:35 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1686147704; cv=none; d=zohomail.com; s=zohoarc; b=bGxpQo+XzInQFXjkuH/VLwf186Ge67LSswMXpN/5LvwBlzFUdraE5Q+f0CHsl5MUErl8S5YcsGdpMGkBFgBYI5a0rS3KEQGZbU3gJ2V0hNcnpXZ7RyU+g5NeGJIe/QLBC83hgP/gmwGSjIPLpC+DOKdybvjmcoJCJpVrjLUp3X8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686147704; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=+U3cojzNJEY9+OwjxAwdgiP6H6Xl6nDkDpCwnecShDc=; b=SEcBAyR7hCgfGFcMklWpaql6txHrIYOgOuJ5Kua/7KBf2C83wOmceavt2mNvL8Sr+9funObcRZ1V31Oux5YiPzKnQHL3sPQCPF8OgOJ/JgvGoQ+l8M64tCtQ+8GWWRku8DuTnKU6EMgGq2q5gRAgfIPUR5OdIp+n41Yvj+S2kEQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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 168614770416485.20663267332259; Wed, 7 Jun 2023 07:21:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6u0m-0002r5-Ed; Wed, 07 Jun 2023 10:19:44 -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 1q6u0k-0002qB-JK for qemu-devel@nongnu.org; Wed, 07 Jun 2023 10:19:42 -0400 Received: from esa1.hc3370-68.iphmx.com ([216.71.145.142]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6u0i-0003PT-WB for qemu-devel@nongnu.org; Wed, 07 Jun 2023 10:19:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1686147580; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KHUNXK6qIii10auVdLh+VILOmUdSI2ZnD9Adc1nNpLA=; b=VlDe/eJbvSsalpP8QvalhmAlBEfRQPW7eypA79+0ove4Dp0gfegTPqFB DZjgL2b5QomcAEcUDJQgyF69Zhjmn1ZCQeA/MoorrgOT8nB4WCdj5m8UI 3IA3viDHZlDrzV+Syf3PxyXag0eTDO8iZjTijUXRMDGzDvI2uFwyx+VyD A=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 112338010 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:iIUwf6zzexoGq2eN0JZ6t+cxxirEfRIJ4+MujC+fZmUNrF6WrkVRz GQfCm+BO6uDZWenfY12a42x80NTscPQzd5iGwtv+CAxQypGp/SeCIXCJC8cHc8wwu7rFxs7s ppEOrEsCOhuExcwcz/0auCJQUFUjP3OHfykTrafYEidfCc8IA85kxVvhuUltYBhhNm9Emult Mj75sbSIzdJ4RYtWo4vw/zF8Es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5IFB/KTH3DU= X-Talos-CUID: =?us-ascii?q?9a23=3Ad1ftfmogWCRARUXQHw0IHYXmUfp0c3HilSmTGkS?= =?us-ascii?q?5CVoqSLDMRXyy9bwxxg=3D=3D?= X-Talos-MUID: 9a23:C6GYRQU0WNtxSYXq/APOv2xrNcYx2qq3DRwIjZsMgZSYBAUlbg== X-IronPort-AV: E=Sophos;i="6.00,224,1681185600"; d="scan'208";a="112338010" To: CC: Bernhard Beschow , Anthony PERARD Subject: [PULL 06/12] hw/pci/pci.c: Don't leak PCIBus::irq_count[] in pci_bus_irqs() Date: Wed, 7 Jun 2023 15:18:33 +0100 Message-ID: <20230607141839.48422-7-anthony.perard@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230607141839.48422-1-anthony.perard@citrix.com> References: <20230607141839.48422-1-anthony.perard@citrix.com> MIME-Version: 1.0 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=216.71.145.142; envelope-from=prvs=51561cf95=anthony.perard@citrix.com; helo=esa1.hc3370-68.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-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: , Reply-to: Anthony PERARD From: Anthony PERARD via Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1686147705411100001 Content-Type: text/plain; charset="utf-8" From: Bernhard Beschow When calling pci_bus_irqs() multiple times on the same object without calli= ng pci_bus_irqs_cleanup() in between PCIBus::irq_count[] is currently leaked. Let's fix this because Xen will do just that in a few commits, and because calling pci_bus_irqs_cleanup() in between seems fragile and cumbersome. Note that pci_bus_irqs_cleanup() now has to NULL irq_count such that pci_bus_irqs() doesn't do a double free. Signed-off-by: Bernhard Beschow Reviewed-by: Michael S. Tsirkin Tested-by: Chuck Zmudzinski Message-Id: <20230403074124.3925-3-shentey@gmail.com> Signed-off-by: Anthony PERARD --- hw/pci/pci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 1cc7c89036..9b7b4d7c18 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -560,6 +560,7 @@ void pci_bus_irqs(PCIBus *bus, pci_set_irq_fn set_irq, bus->set_irq =3D set_irq; bus->irq_opaque =3D irq_opaque; bus->nirq =3D nirq; + g_free(bus->irq_count); bus->irq_count =3D g_malloc0(nirq * sizeof(bus->irq_count[0])); } =20 @@ -575,6 +576,7 @@ void pci_bus_irqs_cleanup(PCIBus *bus) bus->irq_opaque =3D NULL; bus->nirq =3D 0; g_free(bus->irq_count); + bus->irq_count =3D NULL; } =20 PCIBus *pci_register_root_bus(DeviceState *parent, const char *name, --=20 Anthony PERARD