From nobody Wed May 14 10:29:19 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; dkim=fail; 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 1527460153830882.5838625977874; Sun, 27 May 2018 15:29:13 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3B3F530BF440; Sun, 27 May 2018 22:29:12 +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 069BC9420A; Sun, 27 May 2018 22:29:12 +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 ADF8F18033F0; Sun, 27 May 2018 22:29:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4RMSptp015038 for ; Sun, 27 May 2018 18:28:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6E763941E0; Sun, 27 May 2018 22:28:51 +0000 (UTC) Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 651DE93DBC for ; Sun, 27 May 2018 22:28:49 +0000 (UTC) Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BC972315710A for ; Sun, 27 May 2018 22:28:38 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id v131-v6so8142177wma.1 for ; Sun, 27 May 2018 15:28:38 -0700 (PDT) Received: from machado.local ([95.82.135.172]) by smtp.gmail.com with ESMTPSA id h81-v6sm23469897wmd.0.2018.05.27.15.28.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 27 May 2018 15:28:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fidencio-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3pPCwMtFj7Tbbxhkkwdz8JbICFko3VWleZvbfTPvIuc=; b=EfjI7eX/XsjHE43Nk4BYF2+i3elk4gKmuUAhrr6KbH027lgqdwx7N75s9KZLF0cpHT Gw+UdE3JVNX7lsGzxSCVL9bV8byN4IPgjOJcr93HUj6Vyvky1gJzBIYyphfCASmZ6rSt fqqL+tHdaqbB1Po1NQSX3hFuDNoIiB9Lx5EjyFL9ccuXeGQqb25Cb40h63CaB7DItMOc /vS7YHFZrd+OrZjnKbfoTw8F3dvLyQzfkVzZVK3CqQldMkgnjtEKrTrmlZoOE9tv0grD RmbbFzZQGGpVlVgWdgiYScm8R0TW55XQQZu9DL01YdNnteXsBEJrCOK6wxL+gm8mh3r3 vSsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3pPCwMtFj7Tbbxhkkwdz8JbICFko3VWleZvbfTPvIuc=; b=M1aiEz3JsM9waS41x+DOgp97cml6kvZBurR+LUxqNcfWPlZ/cdXNcwhToUOD4oz+h7 c5rfEONjAp2I8Jkoh86G/0aekGMcV9/DP1WYEoqpzQmjSwO+bQsI3dobKrPk9a5nmWd1 E/9On/7kiVilCBjCkffpiX1zQSGTwC+DUfBNDuTTHYqYqVcndiaZNTZRQf7z5i/F9MHt HqcBLtQmeAJLDIZ76TGug6oz/aKHxDLYmhcBuAEk1H95mKZrd5KmoIzJ/jCrTnIWp1O2 zEDTZcJB5oazIWKwgInSfmskg6lxJFL+iASV1Utug+FiopkYkcKOSf4VGDbFQJdnlFTo szCg== X-Gm-Message-State: ALKqPwfOA467ZsGBFUfZtqu+VTHz7sn/yfDo4vzmO6+/h1mAZHTdKKUq sgoGn2GaGNcSUYd2/a2ahl9KNiEU X-Google-Smtp-Source: ADUXVKIAo5+T91PX5rIl3jhJEmhXdE9+P9rjiWwMjvffbUXAcQXbJEGFNW8AthArqwRZ+9QHiBEY1Q== X-Received: by 2002:a1c:6803:: with SMTP id d3-v6mr8209324wmc.70.1527460117188; Sun, 27 May 2018 15:28:37 -0700 (PDT) From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= To: libvir-list@redhat.com Date: Mon, 28 May 2018 00:28:26 +0200 Message-Id: <20180527222826.18525-8-fabiano@fidencio.org> In-Reply-To: <20180527222826.18525-1-fabiano@fidencio.org> References: <20180527222826.18525-1-fabiano@fidencio.org> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Sun, 27 May 2018 22:28:39 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Sun, 27 May 2018 22:28:39 +0000 (UTC) for IP:'74.125.82.66' DOMAIN:'mail-wm0-f66.google.com' HELO:'mail-wm0-f66.google.com' FROM:'fabiano@fidencio.org' RCPT:'' X-RedHat-Spam-Score: 0.08 (DKIM_SIGNED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID) 74.125.82.66 mail-wm0-f66.google.com 74.125.82.66 mail-wm0-f66.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.49 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Subject: [libvirt] [PATCHv3 7/7] xen_common: Fix a few memory leaks 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-Type: text/plain; charset="utf-8" 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.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Sun, 27 May 2018 22:29:12 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 While converting the functions of xen_common to use typesafe virConf acessors, I've spotted a few memory leaks, which are fixed in this patch. Signed-off-by: Fabiano Fid=C3=AAncio --- src/xenconfig/xen_common.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c index 2ba1a19c39..6d9ce9bd66 100644 --- a/src/xenconfig/xen_common.c +++ b/src/xenconfig/xen_common.c @@ -458,14 +458,16 @@ xenParsePCIList(virConfPtr conf, virDomainDefPtr def) for (entries =3D pcis; *entries; entries++) { char *entry =3D *entries; virDomainHostdevDefPtr hostdev; + int rc; =20 if (!(hostdev =3D xenParsePCI(entry))) goto cleanup; =20 - if (VIR_APPEND_ELEMENT(def->hostdevs, def->nhostdevs, hostdev) < 0= ) { - virDomainHostdevDefFree(hostdev); + rc =3D VIR_APPEND_ELEMENT(def->hostdevs, def->nhostdevs, hostdev); + virDomainHostdevDefFree(hostdev); + + if (rc < 0) goto cleanup; - } } =20 ret =3D 0; @@ -787,6 +789,7 @@ xenParseCharDev(virConfPtr conf, virDomainDefPtr def, c= onst char *nativeFormat) =20 for (entries =3D serials; *entries; entries++) { char *port =3D *entries; + int rc; =20 portnum++; if (STREQ(port, "none")) @@ -796,10 +799,11 @@ xenParseCharDev(virConfPtr conf, virDomainDefPtr def,= const char *nativeFormat) goto cleanup; chr->deviceType =3D VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; chr->target.port =3D portnum; - if (VIR_APPEND_ELEMENT(def->serials, def->nserials, chr) <= 0) { - virDomainChrDefFree(chr); + rc =3D VIR_APPEND_ELEMENT(def->serials, def->nserials, chr= ); + virDomainChrDefFree(chr); + + if (rc < 0) goto cleanup; - } } } else { /* If domain is not using multiple serial ports we parse data = old way */ @@ -1047,10 +1051,10 @@ xenParseVifList(virConfPtr conf, virDomainDefPtr de= f, const char *vif_typename) goto cleanup; =20 rc =3D VIR_APPEND_ELEMENT(def->nets, def->nnets, net); - if (rc < 0) { - virDomainNetDefFree(net); + virDomainNetDefFree(net); + + if (rc < 0) goto cleanup; - } } =20 ret =3D 0; --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list