From nobody Tue Dec 16 06:14:50 2025 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 1528477846234887.8998631800325; Fri, 8 Jun 2018 10:10:46 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 803E1C04AC50; Fri, 8 Jun 2018 17:10:44 +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 48EFD68873; Fri, 8 Jun 2018 17:10:44 +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 EDC064CA81; Fri, 8 Jun 2018 17:10:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w58HAOOn019651 for ; Fri, 8 Jun 2018 13:10:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 226572010CA1; Fri, 8 Jun 2018 17:10:24 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-102.phx2.redhat.com [10.3.117.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id D49292010CA0 for ; Fri, 8 Jun 2018 17:10:23 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Fri, 8 Jun 2018 13:10:14 -0400 Message-Id: <20180608171019.32167-2-jferlan@redhat.com> In-Reply-To: <20180608171019.32167-1-jferlan@redhat.com> References: <20180608171019.32167-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/6] vbox: Fix resource leak 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.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 08 Jun 2018 17:10:45 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Need to free the allocated hardDiskToOpen array. The contents of the array are just pointers returned by virVBoxSnapshotConfHardDiskByLocation and not allocated AFAICT so they don't need to also be freed as well. Found by Coverity Signed-off-by: John Ferlan --- src/vbox/vbox_common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 72a24a3464..0e7fe06748 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -4627,6 +4627,8 @@ vboxSnapshotRedefine(virDomainPtr dom, int realReadOnlyDisksPathSize =3D 0; virVBoxSnapshotConfSnapshotPtr newSnapshotPtr =3D NULL; unsigned char snapshotUuid[VIR_UUID_BUFLEN]; + virVBoxSnapshotConfHardDiskPtr *hardDiskToOpen =3D NULL; + size_t hardDiskToOpenSize =3D 0; char **searchResultTab =3D NULL; ssize_t resultSize =3D 0; int it =3D 0; @@ -5080,8 +5082,6 @@ vboxSnapshotRedefine(virDomainPtr dom, */ for (it =3D 0; it < def->dom->ndisks; it++) { char *location =3D NULL; - virVBoxSnapshotConfHardDiskPtr *hardDiskToOpen =3D NULL; - size_t hardDiskToOpenSize =3D 0; =20 location =3D def->dom->disks[it]->src->path; if (!location) @@ -5394,8 +5394,7 @@ vboxSnapshotRedefine(virDomainPtr dom, if (!location) goto cleanup; =20 - virVBoxSnapshotConfHardDiskPtr *hardDiskToOpen =3D NULL; - size_t hardDiskToOpenSize =3D virVBoxSnapshotConfDiskListToOpen(sn= apshotMachineDesc, + hardDiskToOpenSize =3D virVBoxSnapshotConfDiskListToOpen(snapshotM= achineDesc, &hardDiskToOpen, locati= on); for (jt =3D 0; jt < hardDiskToOpenSize; jt++) { IMedium *medium =3D NULL; @@ -5459,6 +5458,7 @@ vboxSnapshotRedefine(virDomainPtr dom, virStringListFree(realReadOnlyDisksPath); virStringListFree(realReadWriteDisksPath); virStringListFree(searchResultTab); + VIR_FREE(hardDiskToOpen); VIR_FREE(newSnapshotPtr); VIR_FREE(machineLocationPath); VIR_FREE(nameTmpUse); --=20 2.14.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list