From nobody Sat May 18 11:25:57 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=1663852054; cv=none; d=zohomail.com; s=zohoarc; b=eDiUrSXJnwWMfWCvUloe6WANTrnAtWcJiml2F2nqgl1eygS63qVq7yPDY+e2rBGNu5f/ljFPAqLEQQtwIEq5yAVFYVP3f+hEZcm2eBhyjQPkbs07gQ54jQqMMUY0NdHa/LwX+9Oue+4D87gx+stCpgAGLAqoxikXgHxN0cOJacI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663852054; 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; bh=mCWNHrpqoePlScFiykrgT9to2ljkLLldTEf2wEtZ4qA=; b=S6Y/oPPMwVmMCRLUgTOnQVmZ8VODwF2jujFqOjKSSk1TNnSOW0xys1CASQ7wozNCmTDlHPbvUShflHDLpjRDJsa6jIAArIaax68oYvZ0rx1hwoGR1WOh5oeI33YGQxgaaPJ1YDhqrGfPGa/ck4iS3L84b9VaHFeAHR7QWPVfP/0= 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 1663852054280238.5702759552721; Thu, 22 Sep 2022 06:07:34 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-574-JEwUnCQONNueYDgv1vpsOw-1; Thu, 22 Sep 2022 09:07:26 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D6C693810798; Thu, 22 Sep 2022 13:07:24 +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 B10FF492CA5; Thu, 22 Sep 2022 13:07:23 +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 687B419465B6; Thu, 22 Sep 2022 13:07:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CE8DB19465A4 for ; Thu, 22 Sep 2022 13:07:11 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id BC5A61121315; Thu, 22 Sep 2022 13:07:11 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B3CE51121314 for ; Thu, 22 Sep 2022 13:07:10 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (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 14E803810798 for ; Thu, 22 Sep 2022 13:07:10 +0000 (UTC) Received: from smtp.cecloud.com (smtp.cecloud.com [106.39.185.58]) by relay.mimecast.com with ESMTP id us-mta-325-rvO6JxkfNBqqFmgQkQg2-Q-1; Thu, 22 Sep 2022 09:07:05 -0400 Received: from localhost (localhost [127.0.0.1]) by smtp.cecloud.com (Postfix) with ESMTP id 64B4417E0207 for ; Thu, 22 Sep 2022 21:00:54 +0800 (CST) Received: from localhost.localdomain (unknown [111.48.58.10]) by smtp.cecloud.com (postfix) whith ESMTP id P2473742T281457150587248S1663851649916082_; Thu, 22 Sep 2022 21:00:54 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663852053; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=mCWNHrpqoePlScFiykrgT9to2ljkLLldTEf2wEtZ4qA=; b=g2Jg9kLxsX7Y5D/8r455YEoWAzUI8MWRV0ugloGmxpQeslLTVMXVwjPS8FCK943WEue4G4 LcsE8uc/s44WjGq/FBz9tF5PXbmnEBT+VkUdBr6e/9DCJY8l10mVvuOvTmSAlX5kGPfHhe OlYHD3ug8Gk5tzu/xIpIWW5i5XCsKZk= X-MC-Unique: JEwUnCQONNueYDgv1vpsOw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: rvO6JxkfNBqqFmgQkQg2-Q-1 X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ANTISPAM-LEVEL: 2 X-ABS-CHECKED: 0 X-IP-DOMAINF: 1 X-UNIQUE-TAG: <0e7fe17824683a7079989346e16196eb> 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] qemu: fix memory leak on some paths Date: Thu, 22 Sep 2022 21:00:38 +0800 Message-Id: <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.3 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.9 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: 1663852059678100001 Content-Type: text/plain; charset="utf-8"; x-default="true" From: lu zhipeng virTypedParamsAddString may return -1 but alloc params, so free it. Signed-off-by: lu zhipeng --- src/qemu/qemu_driver.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 94b70872d4..c4501cd705 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4473,11 +4473,13 @@ qemuDomainPinVcpuLive(virDomainObj *vm, goto cleanup; =20 event =3D virDomainEventTunableNewFromObj(vm, eventParams, eventNparam= s); - + eventNparams =3D 0; ret =3D 0; =20 cleanup: virObjectEventStateQueue(driver->domainEventState, event); + if (eventNparams) + virTypedParamsFree(eventParams, eventNparams); return ret; } =20 @@ -4682,6 +4684,7 @@ qemuDomainPinEmulator(virDomainPtr dom, goto endjob; =20 event =3D virDomainEventTunableNewFromDom(dom, eventParams, eventN= params); + eventNparams =3D 0; } =20 if (persistentDef) { @@ -4700,6 +4703,8 @@ qemuDomainPinEmulator(virDomainPtr dom, cleanup: virObjectEventStateQueue(driver->domainEventState, event); virDomainObjEndAPI(&vm); + if (eventNparams) + virTypedParamsFree(eventParams, eventNparams); return ret; } =20 @@ -5079,6 +5084,7 @@ qemuDomainPinIOThread(virDomainPtr dom, goto endjob; =20 event =3D virDomainEventTunableNewFromDom(dom, eventParams, eventN= params); + eventNparams =3D 0; } =20 if (persistentDef) { @@ -5106,6 +5112,8 @@ qemuDomainPinIOThread(virDomainPtr dom, cleanup: virObjectEventStateQueue(driver->domainEventState, event); virDomainObjEndAPI(&vm); + if (eventNparams) + virTypedParamsFree(eventParams, eventNparams); return ret; } =20 --=20 2.31.1