From nobody Mon Apr 29 21:27:45 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=1568879836; cv=none; d=zoho.com; s=zohoarc; b=U0h81IkOtEvifGtMx4F0FLVE4Ed9/0S1SNXbNwm4fwjFIC1RYL5RRVmEFZ16AfI8fUJc1uEgoKwbV0/tDjgs6Ltpw22Sfd1Cak6s6mflUsHNBML7rMdt7H46tzmZChsCpEQGoFJ/ACaUAMVX3HjBWrVYrit4Bw7HLwWMXO7okts= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568879836; 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=j5Gyv4/6jL1rxjzDAXC4c/FdF1gJojcpcZNScS9SGb4=; b=neuI2lsBIwZyjFE8N7EHlkhKueW7Abc/pyosoExLO4hgnxqfbkQMpdpYrtG/xF2xC4yfIovGfmlMTRjvi0+9ZAfKMgOVyzg+ZP2Eu9nxO6PLre3w5ZmM8gZ9fztBuXoLy0LeUCjmOR3l1tAhI8OrxLJlgEL00H95w7fNeh0qxGA= 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 1568879836055910.3006307477315; Thu, 19 Sep 2019 00:57:16 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DDEDB76521; Thu, 19 Sep 2019 07:57:13 +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 B77E860606; Thu, 19 Sep 2019 07:57:13 +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 7AC3B4EDA7; Thu, 19 Sep 2019 07:57:13 +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 x8J7vBFv032745 for ; Thu, 19 Sep 2019 03:57:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id CA8634518; Thu, 19 Sep 2019 07:57:11 +0000 (UTC) Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C3FB6194B6 for ; Thu, 19 Sep 2019 07:57:09 +0000 (UTC) Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) (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 B0CF43083391 for ; Thu, 19 Sep 2019 07:57:08 +0000 (UTC) Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 44DEA19A7ECA383B6C2E for ; Thu, 19 Sep 2019 15:57:07 +0800 (CST) Received: from localhost (10.175.124.177) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.439.0; Thu, 19 Sep 2019 15:56:58 +0800 From: Xu Yandong To: Date: Thu, 19 Sep 2019 04:02:22 -0400 Message-ID: <1568880142-88315-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.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 19 Sep 2019 07:57:08 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 19 Sep 2019 07:57:08 +0000 (UTC) for IP:'45.249.212.35' DOMAIN:'szxga07-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.35 szxga07-in.huawei.com 45.249.212.35 szxga07-in.huawei.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.44 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] cgroup: cleanup eventParams when virTypedParamsAddULLong failed 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 19 Sep 2019 07:57:14 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Function virTypedParamsAddULLong use realloc to gain memory, and doesn't free it when failed. so we need free eventParams to prevent a memory leak. Signed-off-by: Xu Yandong --- src/qemu/qemu_cgroup.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index ecd96efb0a..bc498e4b10 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -869,8 +869,11 @@ qemuSetupCpuCgroup(virDomainObjPtr vm) if (virTypedParamsAddULLong(&eventParams, &eventNparams, &eventMaxparams, VIR_DOMAIN_TUNABLE_CPU_CPU_SHARES, - val) < 0) + val) < 0) { + if (eventParams) + virTypedParamsFree(eventParams, eventNparams); return -1; + } =20 event =3D virDomainEventTunableNewFromObj(vm, eventParams, eve= ntNparams); } --=20 2.18.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list