From nobody Wed May 8 11:46:54 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 ARC-Seal: i=1; a=rsa-sha256; t=1562684605; cv=none; d=zoho.com; s=zohoarc; b=gpZr+6mWhkx0A6buuDzdbAlv1B0I0JnWBie0i5c+eJc5w6zmzrZsiZncnEyq52tnnnZTmHaGFVRLAboQ2KBF+cugKMukYzRmceqasZICHRnzOY+LDbFVRJIZHOwKvzg/4C1t8ZclbchHLyT3Ji+ZdF95m3L1RRe5yX1MgWkYUfc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562684605; h=Content-Type:Content-Transfer-Encoding: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:ARC-Authentication-Results; bh=kIe2Vd4CtgDnZYk4tEAjbkfRLH3hxxyirUcoDyjKNeo=; b=VTqVFx2r2nx/OmALjDkj5Ft/PiCz/47xe8nuiuOjE4rTgJejnwOqW04a6gGHw5XkAgMcDPKorLn7jQ+tufpVnq4nJurqgcUK2yU1QJyszg915dG+dXfYNz+Yl4K7ZdOFR/QycOTRDPQPchHqgfpv7p//JvyvsLnFYFn5F/E8FTA= 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; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562684605102666.9412734715996; Tue, 9 Jul 2019 08:03:25 -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 6118630013EA; Tue, 9 Jul 2019 15:02:48 +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 D1688831B7; Tue, 9 Jul 2019 15:02:35 +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 7FE381833001; Tue, 9 Jul 2019 15:02:17 +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 x69F2EZh028499 for ; Tue, 9 Jul 2019 11:02:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id BA85D5D70D; Tue, 9 Jul 2019 15:02:14 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 439ED87034 for ; Tue, 9 Jul 2019 15:02:14 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 9 Jul 2019 17:01:56 +0200 Message-Id: <0eed78f8c27b9e8f3bad62ab7aa030750255cf74.1562684480.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/3] virnetworkobj: Free retval of virNetworkObjGetPortStatusDir() 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 09 Jul 2019 15:03:23 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The virNetworkObjGetPortStatusDir() function allocates a memory to construct a path. None of the callers free it leading to a memleak. Signed-off-by: Michal Privoznik Reviewed-by: Erik Skultety --- src/conf/virnetworkobj.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index 12cefebaa8..45726e4016 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -1627,7 +1627,7 @@ virNetworkObjAddPort(virNetworkObjPtr net, { int ret =3D -1; char uuidstr[VIR_UUID_STRING_BUFLEN]; - char *dir =3D NULL; + VIR_AUTOFREE(char *) dir =3D NULL; =20 virUUIDFormat(portdef->uuid, uuidstr); =20 @@ -1717,7 +1717,7 @@ int virNetworkObjDeleteAllPorts(virNetworkObjPtr net, const char *stateDir) { - char *dir; + VIR_AUTOFREE(char *) dir =3D NULL; DIR *dh =3D NULL; struct dirent *de; int rc; @@ -1843,7 +1843,7 @@ static int virNetworkObjLoadAllPorts(virNetworkObjPtr net, const char *stateDir) { - char *dir; + VIR_AUTOFREE(char *) dir =3D NULL; DIR *dh =3D NULL; struct dirent *de; int ret =3D -1; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 11:46:54 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 ARC-Seal: i=1; a=rsa-sha256; t=1562684637; cv=none; d=zoho.com; s=zohoarc; b=gShwHdH+uWTWbZ2aMoGnC3QWoXAFyftBK68Ash1MkcPk+EqNKhP3zW6PjYY3CFFswbdpnRM4H+qdD/kaB+Je400F8rynZ+Ydjzk53H9OB2jQUb7jyz+aZJkEFR03YT5RBA2fY2M/upGLFmc3qgf2oC14EojfzkeMGMdbUOhET9M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562684637; h=Content-Type:Content-Transfer-Encoding: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:ARC-Authentication-Results; bh=Ae1w/JYdyYCWlUSRgbtJsJkiTjL2Cr2QPsZchvjAcE8=; b=bUKNQLXed6zeQOr/gXYSkkaTayNyFVMG/K5ffE9ghH8lTPsUsosWQ9t91qLE4BNrx/U4GsQrV0MgH1R4Xk+ljyp8CrAcKBdtqUJl3HNKJQUlsnEeKMoqB71pOXLP5aPEZy/HEGYWm2/+P4TShSrRJj+rrfWWGk/NgkGFD/hVdfY= 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; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562684637242741.1042076074773; Tue, 9 Jul 2019 08:03:57 -0700 (PDT) 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 680C2309265A; Tue, 9 Jul 2019 15:03:48 +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 4082B1001B29; Tue, 9 Jul 2019 15:03: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 C10061833006; Tue, 9 Jul 2019 15:03:39 +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 x69F2F2i028509 for ; Tue, 9 Jul 2019 11:02:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 85A075D70D; Tue, 9 Jul 2019 15:02:15 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 10EA687034 for ; Tue, 9 Jul 2019 15:02:14 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 9 Jul 2019 17:01:57 +0200 Message-Id: <5121c9967f862a739749570acaa0fb7bfb498902.1562684480.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/3] virnetworkobj: Drop needless cleanup label in virNetworkObjAddPort 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.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.43]); Tue, 09 Jul 2019 15:03:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The cleanup label in virNetworkObjAddPort() function serves no purpose. Drop it and thus simplify the function a bit. Signed-off-by: Michal Privoznik Reviewed-by: Erik Skultety --- src/conf/virnetworkobj.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index 45726e4016..37580b4e76 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -1625,7 +1625,6 @@ virNetworkObjAddPort(virNetworkObjPtr net, virNetworkPortDefPtr portdef, const char *stateDir) { - int ret =3D -1; char uuidstr[VIR_UUID_STRING_BUFLEN]; VIR_AUTOFREE(char *) dir =3D NULL; =20 @@ -1635,24 +1634,21 @@ virNetworkObjAddPort(virNetworkObjPtr net, virReportError(VIR_ERR_NETWORK_PORT_EXIST, _("Network port with UUID %s already exists"), uuidstr); - goto cleanup; + return -1; } =20 if (!(dir =3D virNetworkObjGetPortStatusDir(net, stateDir))) - goto cleanup; + return -1; =20 if (virHashAddEntry(net->ports, uuidstr, portdef) < 0) - goto cleanup; + return -1; =20 if (virNetworkPortDefSaveStatus(portdef, dir) < 0) { virHashRemoveEntry(net->ports, uuidstr); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 8 11:46:54 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 ARC-Seal: i=1; a=rsa-sha256; t=1562684598; cv=none; d=zoho.com; s=zohoarc; b=PJVIOUXDLVz395TRN2ilCpE0yFF1iNRDtqDKklhn6jMAvaIbCCl6VAw+G4IJb9or6Mvr1PhtuV2H0N06LysVvEPJ+TSPq/xXePB7S12YthstUeOS4tFslYPzUlOgSErZYrbGS6EFYiXO7fOl+pxCHdO8A0h0hOfuxwn4RdZ4loI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562684598; h=Content-Type:Content-Transfer-Encoding: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:ARC-Authentication-Results; bh=qkYlZU4YmELzdl7XziHJ+ZzFXhat8FM7M2+BVUexovc=; b=bDek9/d83ZGWWFe8h5dfMphCSfGHPj2ldT4Ggw9uYUCV/Wugh6T7v/KOkOkYK44tRSAD48blAgggWqNEV+ndgJDoNxmeowOY/RzOb/jWI8Hx1oGjgLihdVmQHkD0SlDytd3lcwNCcO6UCmthTkfkFZwwEJ/g6oZGEIupb+8iGUU= 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; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562684598508248.5361584690163; Tue, 9 Jul 2019 08:03:18 -0700 (PDT) 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 8693330C34CB; Tue, 9 Jul 2019 15:02:51 +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 208551001DDA; Tue, 9 Jul 2019 15:02:38 +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 82EAB4EBC0; Tue, 9 Jul 2019 15:02:20 +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 x69F2GUR028517 for ; Tue, 9 Jul 2019 11:02:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5276E8703F; Tue, 9 Jul 2019 15:02:16 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id D0DD25D70D for ; Tue, 9 Jul 2019 15:02:15 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 9 Jul 2019 17:01:58 +0200 Message-Id: <9e385a9660216110289310c535773602b57715cd.1562684480.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/3] virnetworkobj: Drop needless cleanup label in virNetworkObjDeletePort 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.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.40]); Tue, 09 Jul 2019 15:03:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The cleanup label in virNetworkObjDeletePort() function serves no purpose. Drop it and thus simplify the function a bit. Signed-off-by: Michal Privoznik Reviewed-by: Erik Skultety --- src/conf/virnetworkobj.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index 37580b4e76..476f66affc 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -1678,9 +1678,8 @@ virNetworkObjDeletePort(virNetworkObjPtr net, const unsigned char *uuid, const char *stateDir) { - int ret =3D -1; char uuidstr[VIR_UUID_STRING_BUFLEN]; - char *dir =3D NULL; + VIR_AUTOFREE(char *) dir =3D NULL; virNetworkPortDefPtr portdef; =20 virUUIDFormat(uuid, uuidstr); @@ -1689,23 +1688,19 @@ virNetworkObjDeletePort(virNetworkObjPtr net, virReportError(VIR_ERR_NO_NETWORK_PORT, _("Network port with UUID %s does not exist"), uuidstr); - goto cleanup; + return -1; } =20 if (!(dir =3D virNetworkObjGetPortStatusDir(net, stateDir))) - goto cleanup; + return -1; =20 if (virNetworkPortDefDeleteStatus(portdef, dir) < 0) - goto cleanup; + return -1; =20 if (virHashRemoveEntry(net->ports, uuidstr) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - - cleanup: - VIR_FREE(dir); - return ret; + return 0; } =20 =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list