From nobody Fri May 3 10:16:35 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1542222689427664.693978179959; Wed, 14 Nov 2018 11:11:29 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DF56E58E5C; Wed, 14 Nov 2018 19:11:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9F4C31001944; Wed, 14 Nov 2018 19:11:26 +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 E161E18005AD; Wed, 14 Nov 2018 19:11:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAEJ5fKb027734 for ; Wed, 14 Nov 2018 14:05:41 -0500 Received: by smtp.corp.redhat.com (Postfix) id 29B665D75F; Wed, 14 Nov 2018 19:05:41 +0000 (UTC) Received: from unknown4CEB42C824F4.redhat.com (ovpn-116-11.phx2.redhat.com [10.3.116.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id DFF785D759 for ; Wed, 14 Nov 2018 19:05:37 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 14 Nov 2018 14:05:36 -0500 Message-Id: <20181114190536.10652-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] util: Fix memory leak in virResctrlMonitorGetStats 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 14 Nov 2018 19:11:27 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Missed during review and surprisingly my run through Coverity also didn't see this. I only noticed it when reading the code while fixing the build breaker for commit 36780a86a. With all those continues we would leak @stats. Signed-off-by: John Ferlan --- Pushing under trivial rule. src/util/virresctrl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index ef5c668921..7aeca9d287 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -2684,9 +2684,6 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monito= r, while (virDirRead(dirp, &ent, datapath) > 0) { char *node_id =3D NULL; =20 - if (VIR_ALLOC(stat) < 0) - goto cleanup; - /* Looking for directory that contains resource utilization * information file. The directory name is arranged in format * "mon__". For example, "mon_L3_00" and @@ -2709,6 +2706,9 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monito= r, if (!(node_id =3D STRSKIP(node_id, "_"))) continue; =20 + if (VIR_ALLOC(stat) < 0) + goto cleanup; + /* The node ID number should be here, parsing it. */ if (virStrToLong_uip(node_id, NULL, 0, &stat->id) < 0) goto cleanup; --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list