From nobody Tue Apr 30 11:17:22 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1629729253; cv=none; d=zohomail.com; s=zohoarc; b=VsurEjKbnICakuqhtpD95hDubBSuVhyTL5yZUIiyUsozt6kCmXtm2kjSIWJKw5WeXjsZhz2ruOJqJWaZFyHjN/5KFWkfNROeRoNkKNIow9OJc9FaUDw+1HXZGiFJkJYZKCMgZZUURhOD13NyziBq56eQ/3D/39kpa2tnEitDiDs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629729253; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=pF05e3xPVwuaH/JOwTrPgm8ePvEZ9VCvW1AUVhw9Wrw=; b=VAqNZigg9gMHohhaPi7IOhkCeilvVfLdxJ4gMu4geWA5KkPTPQgWcML0Yu6/L/ivKpo/W7z/DwLD6x99ZQmy+1JxIhHWH0ZgseWG9sh8dPbs+w5LfWWVDj1ka0+5DlPYD9mznTqYV+WXh3JPZRfQdJjLkGYuyQVWKRr1Imzodr8= 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; dmarc=pass header.from= (p=none dis=none) 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 1629729253229574.9229777810002; Mon, 23 Aug 2021 07:34:13 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-250-faVNrB4GMdqlthP4T2MGbg-1; Mon, 23 Aug 2021 10:34:10 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 912F9190B2AD; Mon, 23 Aug 2021 14:34:04 +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 32AFA669F3; Mon, 23 Aug 2021 14:34:02 +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 D2084181A2A6; Mon, 23 Aug 2021 14:33:57 +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 17NEXuXL018860 for ; Mon, 23 Aug 2021 10:33:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 405455D740; Mon, 23 Aug 2021 14:33:56 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD37F5D6AD for ; Mon, 23 Aug 2021 14:33:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629729252; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=pF05e3xPVwuaH/JOwTrPgm8ePvEZ9VCvW1AUVhw9Wrw=; b=SsbNjcex8Y+0ibMNLO6L4nmuNK8yKV7RLRM+Kmjb4l1ERkmGwOVZEjOBJjigrFCEylPQNT ifLSLiC48uhWp3YkxZpaoHXdtoxiGZipLL55C/hlT6w5KeNs48j9wAB5mPukh6TDbw8ALk 2G87Bzt/9u06c47gctDaO3emzcmid1w= X-MC-Unique: faVNrB4GMdqlthP4T2MGbg-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH] vbox_network: fix possible memory leak in vboxNetworkDefineCreateXML() Date: Mon, 23 Aug 2021 16:33:41 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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: 1629729254090100001 Content-Type: text/plain; charset="utf-8" virNetworkDef was not freed if the function failed in the first two ifs, causing a possible memory leak. Signed-off-by: Kristina Hanicova Reviewed-by: J=C3=A1n Tomko --- src/vbox/vbox_network.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c index afd2acbb03..d97f571d1b 100644 --- a/src/vbox/vbox_network.c +++ b/src/vbox/vbox_network.c @@ -375,7 +375,7 @@ vboxNetworkDefineCreateXML(virConnectPtr conn, const ch= ar *xml, bool start) PRUnichar *networkNameUtf16 =3D NULL; char *networkNameUtf8 =3D NULL; IHostNetworkInterface *networkInterface =3D NULL; - virNetworkDef *def =3D virNetworkDefParseString(xml, NULL); + virNetworkDef *def =3D NULL; virNetworkIPDef *ipdef =3D NULL; unsigned char uuid[VIR_UUID_BUFLEN]; vboxIID vboxnetiid; @@ -394,7 +394,7 @@ vboxNetworkDefineCreateXML(virConnectPtr conn, const ch= ar *xml, bool start) =20 VBOX_IID_INITIALIZE(&vboxnetiid); =20 - if ((!def) || + if (!(def =3D virNetworkDefParseString(xml, NULL)) || (def->forward.type !=3D VIR_NETWORK_FORWARD_NONE) || (def->nips =3D=3D 0 || !def->ips)) goto cleanup; --=20 2.31.1