From nobody Sun May 5 07:41: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=1568879756; cv=none; d=zoho.com; s=zohoarc; b=diA0BLeCprqeyfR9xKaNE3HSzD4+5rZuAp/8McxoAKW5oK3BMIY21PdY3SG/sQ/aC82q93d6CG24PpQbIy2dkzdNUrzdYB8qN3ihkj8W7OpDiVL74oU7lLwjyu+SnkuqMs7KYB2JWf6TStg5dnj56fiZYG3qMgjod1gUTqEOcm8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568879756; 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=XArDG8hrHi5bDzgY2CgSnKYQ5KI0LOEgxbnZHl8s9gY=; b=iJCA7MDKETg+zlSuAqZhLo5MqiqzVPV1+PpCjBilp5Hk3Cv1AfIlheoPTflzBpmLCcwiIOXUWr3zf8EyI3fRy8cofhE18Cs6ZQ1AUSqiVuaCjPLX09Nnt1uwr6pp84cfb2lD1QtSvgf0PjhOOg99Ru1CA8D/xs/9WHdax3eVtq4= 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 1568879756953827.3984093595006; Thu, 19 Sep 2019 00:55:56 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6434E8553A; Thu, 19 Sep 2019 07:55:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2EC515D6B0; Thu, 19 Sep 2019 07:55:54 +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 8FC314E58A; Thu, 19 Sep 2019 07:55:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8J7taL7032468 for ; Thu, 19 Sep 2019 03:55:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8140A196AE; Thu, 19 Sep 2019 07:55:36 +0000 (UTC) Received: from mx1.redhat.com (ext-mx25.extmail.prod.ext.phx2.redhat.com [10.5.110.66]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7BD1319C5B for ; Thu, 19 Sep 2019 07:55:34 +0000 (UTC) Received: from huawei.com (szxga04-in.huawei.com [45.249.212.190]) (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 0150110CBC4B for ; Thu, 19 Sep 2019 07:55:33 +0000 (UTC) Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id CF456D705B2F70100EE5 for ; Thu, 19 Sep 2019 15:55:29 +0800 (CST) Received: from localhost (10.175.124.177) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.439.0; Thu, 19 Sep 2019 15:55:23 +0800 From: Xu Yandong To: Date: Thu, 19 Sep 2019 04:00:46 -0400 Message-ID: <1568880046-87830-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.66]); Thu, 19 Sep 2019 07:55:33 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.66]); Thu, 19 Sep 2019 07:55:33 +0000 (UTC) for IP:'45.249.212.190' DOMAIN:'szxga04-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.190 szxga04-in.huawei.com 45.249.212.190 szxga04-in.huawei.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.66 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Xu Yandong , zhang.zhanghailiang@huawei.com Subject: [libvirt] [PATCH] qemu: fix potential memory leak 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 19 Sep 2019 07:55:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" function virTypedParamsAddString may return -1 but alloc params, so invoker should free it. Signed-off-by: Xu Yandong --- src/qemu/qemu_driver.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 1e041a8bac..62ce7270ca 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5312,6 +5312,8 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm, goto cleanup; =20 event =3D virDomainEventTunableNewFromObj(vm, eventParams, eventNparam= s); + eventParams =3D NULL; + eventNparams =3D 0; =20 ret =3D 0; =20 @@ -5320,6 +5322,8 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm, virCgroupFree(&cgroup_vcpu); VIR_FREE(str); virObjectEventStateQueue(driver->domainEventState, event); + if (eventParams) + virTypedParamsFree(eventParams, eventNparams); return ret; } =20 @@ -5527,6 +5531,8 @@ qemuDomainPinEmulator(virDomainPtr dom, goto endjob; =20 event =3D virDomainEventTunableNewFromDom(dom, eventParams, eventN= params); + eventParams =3D NULL; + eventNparams =3D 0; } =20 if (persistentDef) { @@ -5548,6 +5554,8 @@ qemuDomainPinEmulator(virDomainPtr dom, cleanup: if (cgroup_emulator) virCgroupFree(&cgroup_emulator); + if (eventParams) + virTypedParamsFree(eventParams, eventNparams); virObjectEventStateQueue(driver->domainEventState, event); VIR_FREE(str); virBitmapFree(pcpumap); @@ -6012,6 +6020,8 @@ qemuDomainPinIOThread(virDomainPtr dom, goto endjob; =20 event =3D virDomainEventTunableNewFromDom(dom, eventParams, eventN= params); + eventParams =3D NULL; + eventNparams =3D 0; } =20 if (persistentDef) { @@ -6043,6 +6053,8 @@ qemuDomainPinIOThread(virDomainPtr dom, cleanup: if (cgroup_iothread) virCgroupFree(&cgroup_iothread); + if (eventParams) + virTypedParamsFree(eventParams, eventNparams); virObjectEventStateQueue(driver->domainEventState, event); VIR_FREE(str); virBitmapFree(pcpumap); --=20 2.18.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list