From nobody Fri May 17 22:37:07 2024 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=1664193410; cv=none; d=zohomail.com; s=zohoarc; b=W61B2MygUumgbo8a87PzuJcCUv43tjA3/xzi5itqewxNw1sGEM7xawri0bOBZ17uDM3M3TrHprT0uTedwhi/H9CtEi14FrHM5w8wG0Cy4U5VEW28M5aiMp8guQ/o2IKH+DKYwAOxEdbWj5dOteJJmYdevhfHC4VsP3hwOphcPmw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664193410; 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=hTUZecuy4F/maxxOr06fMNaSd99+mRQ4I02RSvXwJ5A=; b=oHja9NWo/EyCP/06EWssM734AO/CnocuYBhXfQhiF3Pj7u8H7ZnTtJhHTsrtsM4iFQVVh3a0wynOnfEr1zCYjtPtqii96P44R83jSSv9AOkYLsn+BkXSPyHEYoZMm25veJEcUWs2iI+R5/FkZlqM44HZFrvh6rUPlPJJRuac/BE= 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 166419340980126.89772758976153; Mon, 26 Sep 2022 04:56:49 -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-290-W9OLxBJiMSSEiB5x3qDWiQ-1; Mon, 26 Sep 2022 07:56:44 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A1C70101A52A; Mon, 26 Sep 2022 11:56:42 +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 4B1F0492B04; Mon, 26 Sep 2022 11:56:41 +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 26CCB194658D; Mon, 26 Sep 2022 11:56:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1284E1946586 for ; Mon, 26 Sep 2022 11:56:40 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E721E40C6EC3; Mon, 26 Sep 2022 11:56:39 +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 DF22740C6EC2 for ; Mon, 26 Sep 2022 11:56:39 +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 C414E185A7A3 for ; Mon, 26 Sep 2022 11:56:39 +0000 (UTC) Received: from smtp.cecloud.com (smtp.cecloud.com [106.39.185.58]) by relay.mimecast.com with ESMTP id us-mta-564-JFpM_r5vPmykYCuVsyBONw-1; Mon, 26 Sep 2022 07:56:36 -0400 Received: from localhost (localhost [127.0.0.1]) by smtp.cecloud.com (Postfix) with ESMTP id B877817E0209 for ; Mon, 26 Sep 2022 19:56:33 +0800 (CST) Received: from localhost.localdomain (unknown [111.48.58.10]) by smtp.cecloud.com (postfix) whith ESMTP id P2473742T281457410568560S1664193391958319_; Mon, 26 Sep 2022 19:56:33 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664193408; 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=hTUZecuy4F/maxxOr06fMNaSd99+mRQ4I02RSvXwJ5A=; b=IQDGg93dzFLHsEK/pS7A0sGVd5MunMi4pqUSOFjWCxG5CTyZ0NbzPC0WyWizTRYXzWbGmi Z/R3ifU+1AWbr6YtE4V0355k6vS4Wn5BMIBWSz2t3XGIXP/B3ExTNjok0l2C+nVtjkcQNs Q2wJtVQQd6wgF54Ewg86DImzsRVkgJY= X-MC-Unique: W9OLxBJiMSSEiB5x3qDWiQ-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: JFpM_r5vPmykYCuVsyBONw-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: 111.48.58.10 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: Mon, 26 Sep 2022 19:55:52 +0800 Message-Id: <20220926115553.1220-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.2 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.10 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: 1664193411490100001 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 Reviewed-by: Jiri Denemark --- src/conf/domain_event.c | 14 +++++++------- src/conf/domain_event.h | 4 ++-- src/qemu/qemu_driver.c | 22 ++++++++++------------ src/remote/remote_driver.c | 2 +- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c index ff8ea2c389..ff39975104 100644 --- a/src/conf/domain_event.c +++ b/src/conf/domain_event.c @@ -1495,8 +1495,8 @@ static virObjectEvent * virDomainEventTunableNew(int id, const char *name, unsigned char *uuid, - virTypedParameterPtr params, - int nparams) + virTypedParameterPtr *params, + int nparams) { virDomainEventTunable *ev; =20 @@ -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