From patchwork Tue Dec 12 12:18:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 753049 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c83:0:b0:333:3a04:f257 with SMTP id z3csp1867963wrs; Tue, 12 Dec 2023 04:21:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IFxEW4XhQUB1jpKWBTye8zd/Mp4GfA/5194a1Nmuxkh2BiL837HCWhFTHH0d1zULx3d5K3k X-Received: by 2002:a37:c444:0:b0:77f:6ec:4b0b with SMTP id h4-20020a37c444000000b0077f06ec4b0bmr7082675qkm.140.1702383666605; Tue, 12 Dec 2023 04:21:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702383666; cv=none; d=google.com; s=arc-20160816; b=JOtydWY+HGtOCKGhI0aTJJnQ8htSf6zx3VjRGsKSgAJeTuzKc7q0yshCOJlH5bCjwe C5K+Ik3Xn6hvINkUAgmbbnsx03+3l7yzL+AUFSZw5CZn0O4WDXhLobhLa3XjNK3E36dr gs0HQMsatGATInAxc8pSqXms+cKzU1GY6pN+0Oc4rZB2pPIx9Yb32m1cDp21+bEPJWB+ stKxTcyEHcczrPE+3sHGvITxF/xmxVVxAl1zZDT3OZX7HUXTp43yZDuf7clzgZeQXhhL QEmmiYj950pnN2VEdVQdxeRSOIVrj1tV4Kom05RNp9B0nuqLXsKMORynfn4IWVswGxb4 EfYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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; bh=qGQz/jE/sFM047+EWZMtPX7y9WaU6Lnbw5Cw9Csejk0=; fh=PenDYrn8i21Yvsbn+uxcw5oiVY7iec7IJ9Kf8KemhZE=; b=prkAOaR2ERu+c+c7HxbqQmk4Wy/wbNbvNHZyjHO+AegXD0bMvaxDoDtLIqSIlvceV/ WESIXyOpeaO3rnfkWjkuF5mqeh0vE628BIknnl6IzQlv5fKFq/ENrZV/zSAOVmT3+OQB lJQEe5M34XVB1ZADv9N/NpZd6aHEdFu6bmLd0KZfb63+ihjNLhA1QPwKTwosZIGM+t/3 ObdUNXPP2qXc1RvRil1cn2MVWE8GsqiMFWqcShPF0lX2vwLJbhp1FQsUHeJbpVqTAbog mqE6JEiCCynS4bFDsWfwkAy9KZcfcKx9PMe5P04RpSyleyV2T73f7NFiRB1k2gHFSxPq 70Rw== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bq42-20020a05620a46aa00b0077d98c41377si11043014qkb.442.2023.12.12.04.21.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Dec 2023 04:21:06 -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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rD1k5-0006Xb-Mt; Tue, 12 Dec 2023 07:20:06 -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 1rD1jy-0006A1-Fe; Tue, 12 Dec 2023 07:19:58 -0500 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rD1jw-0000UR-K1; Tue, 12 Dec 2023 07:19:58 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 0E2DE3AF05; Tue, 12 Dec 2023 15:18:50 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id C66293B953; Tue, 12 Dec 2023 15:18:32 +0300 (MSK) Received: (nullmailer pid 1003450 invoked by uid 1000); Tue, 12 Dec 2023 12:18:31 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Eric Auger , Peter Maydell , Michael Tokarev Subject: [Stable-8.1.4 17/31] hw/virtio: Free VirtIOIOMMUPCI::vdev.reserved_regions[] on finalize() Date: Tue, 12 Dec 2023 15:18:05 +0300 Message-Id: <20231212121831.1003318-17-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, 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 From: Philippe Mathieu-Daudé Commit 0be6bfac62 ("qdev: Implement variable length array properties") added the DEFINE_PROP_ARRAY() macro with the following comment: * It is the responsibility of the device deinit code to free the * @_arrayfield memory. Commit 8077b8e549 added: DEFINE_PROP_ARRAY("reserved-regions", VirtIOIOMMUPCI, vdev.nb_reserved_regions, vdev.reserved_regions, qdev_prop_reserved_region, ReservedRegion), but forgot to free the 'vdev.reserved_regions' array. Do it in the instance_finalize() handler. Cc: qemu-stable@nongnu.org Fixes: 8077b8e549 ("virtio-iommu-pci: Add array of Interval properties") # v5.1.0+ Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Eric Auger Message-id: 20231121174051.63038-3-philmd@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell (cherry picked from commit c9a4aa06dfce0fde1e279e1ea0c1945582ec0d16) Signed-off-by: Michael Tokarev (Mjt: fixup hw/virtio/virtio-iommu-pci.c for before v8.1.0-2552-g41cc70cdf5, "virtio-iommu: Rename reserved_regions into prop_resv_regions" -- so now patch subject matches actual change again) diff --git a/hw/virtio/virtio-iommu-pci.c b/hw/virtio/virtio-iommu-pci.c index 7ef2f9dcdb..eab6e1c793 100644 --- a/hw/virtio/virtio-iommu-pci.c +++ b/hw/virtio/virtio-iommu-pci.c @@ -95,10 +95,18 @@ static void virtio_iommu_pci_instance_init(Object *obj) TYPE_VIRTIO_IOMMU); } +static void virtio_iommu_pci_instance_finalize(Object *obj) +{ + VirtIOIOMMUPCI *dev = VIRTIO_IOMMU_PCI(obj); + + g_free(dev->vdev.reserved_regions); +} + static const VirtioPCIDeviceTypeInfo virtio_iommu_pci_info = { .generic_name = TYPE_VIRTIO_IOMMU_PCI, .instance_size = sizeof(VirtIOIOMMUPCI), .instance_init = virtio_iommu_pci_instance_init, + .instance_finalize = virtio_iommu_pci_instance_finalize, .class_init = virtio_iommu_pci_class_init, };