From nobody Mon Feb 9 09:29:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1663942169; cv=none; d=zohomail.com; s=zohoarc; b=OIhakN7Iyo2mPLxJON8O6bTKo0vXemE/YVu0jBAmMTARKitc9kZQZdbj/c5ZambkCeDRzwHH9ql0EufRpAtAuvzxfTggmXCO8sAirD6NrXg8dUcTn/XKlQxtKoC3DvnkcbG7B3XGgiKuIdxkp9jDK/acNFBa+TpHrFJsEiJ+5k0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663942169; 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:References:Sender:Subject:To; bh=iT/s50ouPGxXbfw24fqCe5cB44U/7L1q/fLEQno47uM=; b=GqdQz7wS7owJKAa3UXPvFaCMKR2UhYc7FaIEFcHaXcSNMlpPYGwM3ckJ0tPaJOvjy3LXV9BwsYXANHwjcoQ+OqrDsXWFXZQ7Zm4PJZAm9ZtV1SqNsJsRt8LW4znQ/FwgUSCLWlBikT9h2ZhRLw5iccZ3Jk/C6YdOsnh/uXiN2kg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1663942169403633.7963541125083; Fri, 23 Sep 2022 07:09:29 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-530-NnXwRaHIPEea7awxy11FIQ-1; Fri, 23 Sep 2022 10:09:26 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5DDE3101245E; Fri, 23 Sep 2022 14:09:21 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 019AB112131B; Fri, 23 Sep 2022 14:09:21 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C4CA019465B7; Fri, 23 Sep 2022 14:09:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8CDD019465A4 for ; Fri, 23 Sep 2022 14:09:19 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6F9D62166B5D; Fri, 23 Sep 2022 14:09:19 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6860E2166B35 for ; Fri, 23 Sep 2022 14:09:19 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4B499185A7AB for ; Fri, 23 Sep 2022 14:09:19 +0000 (UTC) Received: from smtp.cecloud.com (smtp.cecloud.com [106.39.185.58]) by relay.mimecast.com with ESMTP id us-mta-556-_WAjNKtyM5S8hWuO0CT9AA-1; Fri, 23 Sep 2022 10:09:14 -0400 Received: from localhost (localhost [127.0.0.1]) by smtp.cecloud.com (Postfix) with ESMTP id 930C017E0206 for ; Fri, 23 Sep 2022 22:09:10 +0800 (CST) Received: from localhost.localdomain (1.39.88.218.broad.cd.sc.dynamic.163data.com.cn [218.88.39.1]) by smtp.cecloud.com (postfix) whith ESMTP id P2473742T281457461293424S1663942146077457_; Fri, 23 Sep 2022 22:09:10 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663942168; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=iT/s50ouPGxXbfw24fqCe5cB44U/7L1q/fLEQno47uM=; b=TwCx84CMW4vy+JLqEQztAryGn/W3KVmXv+P0PlNxVorImmGLFfHkrY6N14dgSk2JRScq/o egUzAIl/1+AhjBECRd+1P9QKLFAuxxxs2PR6VngT8IYqqQCsM/OCSgUzL/BMWpnKpHKpPT bu24hBrpqIr/tV1+Fci7UkYsNQ8gWOc= X-MC-Unique: NnXwRaHIPEea7awxy11FIQ-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: _WAjNKtyM5S8hWuO0CT9AA-1 X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ANTISPAM-LEVEL: 2 X-ABS-CHECKED: 0 X-IP-DOMAINF: 1 X-UNIQUE-TAG: X-RL-SENDER: luzhipeng@cestc.cn X-SENDER: luzhipeng@cestc.cn X-LOGIN-NAME: luzhipeng@cestc.cn X-FST-TO: libvir-list@redhat.com X-RCPT-COUNT: 2 X-SENDER-IP: 218.88.39.1 X-ATTACHMENT-NUM: 0 X-System-Flag: 0 From: luzhipeng To: libvir-list@redhat.com Subject: [PATCH v2 RESEND] qemu: fix memory leak about virDomainEventTunableNew Date: Fri, 23 Sep 2022 22:08:42 +0800 Message-Id: <20220923140842.1580-1-luzhipeng@cestc.cn> In-Reply-To: <'20220922130038.1616-1-luzhipeng@cestc.cn'> References: <'20220922130038.1616-1-luzhipeng@cestc.cn'> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Mimecast-Spam-Signature: yes X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lu zhipeng Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1663942170456100001 Content-Type: text/plain; charset="utf-8"; x-default="true" From: lu zhipeng For prevent memory leak and easier to use, So change virDomainEventTunableNew to get virTypedParameterPtr *params and set it =3D NULL. Signed-off-by: lu zhipeng --- v1: https://patchew.org/Libvirt/20220922130038.1616-1-luzhipeng@cestc.cn/ src/conf/domain_event.c | 12 ++++++------ src/conf/domain_event.h | 4 ++-- src/qemu/qemu_driver.c | 22 ++++++++++------------ src/remote/remote_driver.c | 2 +- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c index ff8ea2c389..97d58c2521 100644 --- a/src/conf/domain_event.c +++ b/src/conf/domain_event.c @@ -1495,7 +1495,7 @@ static virObjectEvent * virDomainEventTunableNew(int id, const char *name, unsigned char *uuid, - virTypedParameterPtr params, + virTypedParameterPtr *params, int nparams) { virDomainEventTunable *ev; @@ -1508,19 +1508,19 @@ virDomainEventTunableNew(int id, id, name, uuid))) goto error; =20 - ev->params =3D params; + ev->params =3D *params; ev->nparams =3D nparams; - + *params =3D NULL; return (virObjectEvent *)ev; =20 error: - virTypedParamsFree(params, nparams); + virTypedParamsFree(*params, nparams); return NULL; } =20 virObjectEvent * virDomainEventTunableNewFromObj(virDomainObj *obj, - virTypedParameterPtr params, + virTypedParameterPtr *params, int nparams) { return virDomainEventTunableNew(obj->def->id, @@ -1532,7 +1532,7 @@ virDomainEventTunableNewFromObj(virDomainObj *obj, =20 virObjectEvent * virDomainEventTunableNewFromDom(virDomainPtr dom, - virTypedParameterPtr params, + virTypedParameterPtr *params, int nparams) { return virDomainEventTunableNew(dom->id, diff --git a/src/conf/domain_event.h b/src/conf/domain_event.h index 4a9f6b988b..f4016dc1e9 100644 --- a/src/conf/domain_event.h +++ b/src/conf/domain_event.h @@ -195,11 +195,11 @@ virDomainEventDeviceRemovalFailedNewFromDom(virDomain= Ptr dom, =20 virObjectEvent * virDomainEventTunableNewFromObj(virDomainObj *obj, - virTypedParameterPtr params, + virTypedParameterPtr *params, int nparams); virObjectEvent * virDomainEventTunableNewFromDom(virDomainPtr dom, - virTypedParameterPtr params, + virTypedParameterPtr *params, int nparams); =20 virObjectEvent * diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 94b70872d4..3db4592945 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4472,12 +4472,12 @@ qemuDomainPinVcpuLive(virDomainObj *vm, &eventMaxparams, paramField, str) < 0) goto cleanup; =20 - event =3D virDomainEventTunableNewFromObj(vm, eventParams, eventNparam= s); + event =3D virDomainEventTunableNewFromObj(vm, &eventParams, eventNpara= ms); ret =3D 0; =20 cleanup: virObjectEventStateQueue(driver->domainEventState, event); + virTypedParamsFree(eventParams, eventNparams); return ret; } =20 @@ -4681,7 +4681,7 @@ qemuDomainPinEmulator(virDomainPtr dom, str) < 0) goto endjob; =20 - event =3D virDomainEventTunableNewFromDom(dom, eventParams, eventN= params); + event =3D virDomainEventTunableNewFromDom(dom, &eventParams, event= Nparams); } =20 if (persistentDef) { @@ -4700,6 +4700,7 @@ qemuDomainPinEmulator(virDomainPtr dom, cleanup: virObjectEventStateQueue(driver->domainEventState, event); virDomainObjEndAPI(&vm); + virTypedParamsFree(eventParams, eventNparams); return ret; } =20 @@ -5078,7 +5079,7 @@ qemuDomainPinIOThread(virDomainPtr dom, &eventMaxparams, paramField, str) < 0) goto endjob; =20 - event =3D virDomainEventTunableNewFromDom(dom, eventParams, eventN= params); + event =3D virDomainEventTunableNewFromDom(dom, &eventParams, event= Nparams); } =20 if (persistentDef) { @@ -5106,6 +5107,7 @@ qemuDomainPinIOThread(virDomainPtr dom, cleanup: virObjectEventStateQueue(driver->domainEventState, event); virDomainObjEndAPI(&vm); + virTypedParamsFree(eventParams, eventNparams); return ret; } =20 @@ -9633,8 +9635,7 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr do= m, qemuDomainSaveStatus(vm); =20 if (eventNparams) { - event =3D virDomainEventTunableNewFromDom(dom, eventParams, eventN= params); - eventNparams =3D 0; + event =3D virDomainEventTunableNewFromDom(dom, &eventParams, event= Nparams); virObjectEventStateQueue(driver->domainEventState, event); } =20 @@ -9654,8 +9655,7 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr do= m, =20 cleanup: virDomainObjEndAPI(&vm); - if (eventNparams) - virTypedParamsFree(eventParams, eventNparams); + virTypedParamsFree(eventParams, eventNparams); return ret; } #undef SCHED_RANGE_CHECK @@ -16159,8 +16159,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, qemuDomainSaveStatus(vm); =20 if (eventNparams) { - event =3D virDomainEventTunableNewFromDom(dom, eventParams, ev= entNparams); - eventNparams =3D 0; + event =3D virDomainEventTunableNewFromDom(dom, &eventParams, e= ventNparams); virObjectEventStateQueue(driver->domainEventState, event); } } @@ -16202,8 +16201,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, VIR_FREE(info.group_name); VIR_FREE(conf_info.group_name); virDomainObjEndAPI(&vm); - if (eventNparams) - virTypedParamsFree(eventParams, eventNparams); + virTypedParamsFree(eventParams, eventNparams); return ret; } =20 diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index a4efe101a3..b0dba9057b 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -5078,7 +5078,7 @@ remoteDomainBuildEventCallbackTunable(virNetClientPro= gram *prog G_GNUC_UNUSED, return; } =20 - event =3D virDomainEventTunableNewFromDom(dom, params, nparams); + event =3D virDomainEventTunableNewFromDom(dom, ¶ms, nparams); =20 virObjectUnref(dom); =20 --=20 2.31.1