From nobody Mon Apr 29 03:21:08 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.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; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1492103282488103.60626573533659; Thu, 13 Apr 2017 10:08:02 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 78D094E02D; Thu, 13 Apr 2017 17:08:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E74017E8E5; Thu, 13 Apr 2017 17:07:59 +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 90BBF5EC67; Thu, 13 Apr 2017 17:07:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v3DH7ua9009102 for ; Thu, 13 Apr 2017 13:07:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id D0E507C751; Thu, 13 Apr 2017 17:07:56 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C71F47C74E for ; Thu, 13 Apr 2017 17:07:55 +0000 (UTC) Received: from smtp2.provo.novell.com (smtp2.provo.novell.com [137.65.250.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B0CDB3DBEA for ; Thu, 13 Apr 2017 17:07:53 +0000 (UTC) Received: from linux-tbji.provo.novell.com (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (NOT encrypted); Thu, 13 Apr 2017 11:07:51 -0600 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 78D094E02D Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 78D094E02D DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B0CDB3DBEA Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jfehlig@suse.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B0CDB3DBEA From: Jim Fehlig To: libvir-list@redhat.com Date: Thu, 13 Apr 2017 11:07:41 -0600 Message-Id: <20170413170741.29345-1-jfehlig@suse.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 203 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 13 Apr 2017 17:07:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 13 Apr 2017 17:07:54 +0000 (UTC) for IP:'137.65.250.81' DOMAIN:'smtp2.provo.novell.com' HELO:'smtp2.provo.novell.com' FROM:'jfehlig@suse.com' RCPT:'' X-RedHat-Spam-Score: -1.501 (BAYES_50, RCVD_IN_DNSWL_MED, SPF_PASS) 137.65.250.81 smtp2.provo.novell.com 137.65.250.81 smtp2.provo.novell.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] xenconfig: avoid double free on OOM testing 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 13 Apr 2017 17:08:01 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Fix xlconfig channel tests when OOM testing is enabled. TEST: xlconfigtest 32) Xen XL-2-XML Format channel-unix ... OK Test OOM for nalloc=3D55 ..............................................= ..*** Error in `/home/jfehlig/virt/upstream/libvirt/tests/.libs/xlconfigtes= t': double free or corruption (fasttop): 0x0000000000679550 *** ... (gdb) bt #0 0x00007ffff36875af in raise () from /lib64/libc.so.6 #1 0x00007ffff36889aa in abort () from /lib64/libc.so.6 #2 0x00007ffff36c5150 in __libc_message () from /lib64/libc.so.6 #3 0x00007ffff36cb4f6 in malloc_printerr () from /lib64/libc.so.6 #4 0x00007ffff36cbcee in _int_free () from /lib64/libc.so.6 #5 0x00007ffff782babf in virFree (ptrptr=3D0x7fffffffdca8) at util/virallo= c.c:582 #6 0x000000000042f2f3 in xenParseXLChannel (conf=3D0x677350, def=3D0x6815b= 0) at xenconfig/xen_xl.c:788 #7 0x000000000042f44e in xenParseXL (conf=3D0x677350, caps=3D0x6832b0, xml= opt=3D0x67f6e0) at xenconfig/xen_xl.c:828 #8 0x00000000004105a3 in testCompareFormatXML ( xlcfg=3D0x6811e0 "/home/jfehlig/virt/upstream/libvirt/tests/xlconfigdat= a/test-channel-unix.cfg", xml=3D0x681110 "/home/jfehlig/virt/upstream/libvirt/tests/xlconfigdata/= test-channel-unix.xml", replaceVars=3Dfalse) at xlconfigtest.c:152 When a channel is successfully parsed and its path and name fields assigned from local variables, set the local variables to NULL to prevent a double free on error. Signed-off-by: Jim Fehlig --- src/xenconfig/xen_xl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c index 43ecf4114..a5b342a86 100644 --- a/src/xenconfig/xen_xl.c +++ b/src/xenconfig/xen_xl.c @@ -759,8 +759,9 @@ xenParseXLChannel(virConfPtr conf, virDomainDefPtr def) =20 if (STRPREFIX(type, "socket")) { channel->source->type =3D VIR_DOMAIN_CHR_TYPE_UNIX; - channel->source->data.nix.path =3D path; channel->source->data.nix.listen =3D 1; + channel->source->data.nix.path =3D path; + path =3D NULL; } else if (STRPREFIX(type, "pty")) { channel->source->type =3D VIR_DOMAIN_CHR_TYPE_PTY; VIR_FREE(path); @@ -771,6 +772,7 @@ xenParseXLChannel(virConfPtr conf, virDomainDefPtr def) channel->deviceType =3D VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL; channel->targetType =3D VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_XEN; channel->target.name =3D name; + name =3D NULL; =20 if (VIR_APPEND_ELEMENT(def->channels, def->nchannels, channel)= < 0) goto cleanup; --=20 2.11.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list