From nobody Sun May 5 01:51:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1568879821; cv=none; d=zoho.com; s=zohoarc; b=bvk+0xpRIbMGVvQwQ0Mer/UTwBWP/Mmqfej4x8pydcjIZdVESHU9LLvqF49Tt86VPSGlV+GsyjPCHxN+pjNS8mz23fHqZqDWDabGqkgUPDuqOeredheKVi3aB9Djo25dd3uELoOXm8vXGIOJxFRjYtuhg53oljaRy21rTnzQxQw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568879821; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=M0hAnRyIWqS+f/YiRUxQ35j4ZucOenlLm8zGX/O9+WI=; b=PzQI4odbCL9VNL6WQFzO0IrZA/DLA7Vr2kQvO2AMNQMAjyot2PCAMH9KjwFIuCGNr1h7AXrPU2TEHMLkxCDkLOV1UaJLuVW2Ke7VsJGQvoHrjqKkiSa2nJE42oAbH1wvSt512hhzbTDhnY1PwSVAE4BxIK8xgvL2BWIW49qMdXE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1568879821879776.4655216351811; Thu, 19 Sep 2019 00:57:01 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F2950308212A; Thu, 19 Sep 2019 07:56:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CCA595D9E5; Thu, 19 Sep 2019 07:56:59 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8DBE318037C9; Thu, 19 Sep 2019 07:56:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8J7uvrV032671 for ; Thu, 19 Sep 2019 03:56:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id A914E5DA8C; Thu, 19 Sep 2019 07:56:57 +0000 (UTC) Received: from mx1.redhat.com (ext-mx22.extmail.prod.ext.phx2.redhat.com [10.5.110.63]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A40E95DA60 for ; Thu, 19 Sep 2019 07:56:54 +0000 (UTC) Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4BED918CB8EA for ; Thu, 19 Sep 2019 07:56:54 +0000 (UTC) Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id D4321A2516A8922E093B for ; Thu, 19 Sep 2019 15:56:52 +0800 (CST) Received: from localhost (10.175.124.177) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.439.0; Thu, 19 Sep 2019 15:56:43 +0800 From: Xu Yandong To: Date: Thu, 19 Sep 2019 04:02:07 -0400 Message-ID: <1568880127-88222-1-git-send-email-xuyandong2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.177] X-CFilter-Loop: Reflected X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.63]); Thu, 19 Sep 2019 07:56:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.63]); Thu, 19 Sep 2019 07:56:54 +0000 (UTC) for IP:'45.249.212.191' DOMAIN:'szxga05-in.huawei.com' HELO:'huawei.com' FROM:'xuyandong2@huawei.com' RCPT:'' X-RedHat-Spam-Score: -2.302 (RCVD_IN_DNSWL_MED, SPF_HELO_PASS, SPF_PASS) 45.249.212.191 szxga05-in.huawei.com 45.249.212.191 szxga05-in.huawei.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.63 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Xu Yandong , zhang.zhanghailiang@huawei.com Subject: [libvirt] [PATCH] qemu_conf: clear domain before VIR_DELETE_ELEMENT X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 19 Sep 2019 07:57:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The macro VIR_DELETE_ELEMENT assume that the items being deleted have already been cleared, so we must explicitly delete domain memory to prevent a memory leak. Signed-off-by: Xu Yandong Reviewed-by: Michal Privoznik --- src/qemu/qemu_conf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 1aeec30f8a..db390d358e 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1620,10 +1620,12 @@ qemuSharedDeviceEntryRemove(virQEMUDriverPtr driver, if (!qemuSharedDeviceEntryDomainExists(entry, name, &idx)) return 0; =20 - if (entry->ref !=3D 1) + if (entry->ref !=3D 1) { + VIR_FREE(entry->domains[idx]); VIR_DELETE_ELEMENT(entry->domains, idx, entry->ref); - else + } else { ignore_value(virHashRemoveEntry(driver->sharedDevices, key)); + } =20 return 0; } --=20 2.18.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list