From patchwork Tue Jan 22 19:26:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: dann frazier X-Patchwork-Id: 156319 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp7965110jaa; Tue, 22 Jan 2019 11:36:08 -0800 (PST) X-Google-Smtp-Source: ALg8bN7+/Hrf4rzdfpkc5xAShOW4WSOHmEGsijv8yHT1eVuMbWhFK8PHn6F7n034VT2JPVSKItN5 X-Received: by 2002:a0c:d933:: with SMTP id p48mr31524294qvj.15.1548185768819; Tue, 22 Jan 2019 11:36:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548185768; cv=none; d=google.com; s=arc-20160816; b=HYmsRhNKS2fi3O9L+te+h/IPJ9V5p6Tbh7wiRz8iTztQTyT0hwn+h2iKC3Jg6AlbHX NfCOrKhi1RiQ8DQUbDvASbBNcL6hKS2v6z19haZR3LLnlFUK5VkgeQBEIn0shmopsCiE 57gR6s5TnKtpwKY35cyBTz9u+HYMqN5JdO0QO98GIYRQ4UGeNyaIJuxtF5MVB+rVYt4w +k44tu4jTmwcQ9Ir6LD3b0ALh35RBtvO62QkdJd0nFwQ+3xfOXM3Hk5DoyT+DS0cCC6b vlgMecMRvRFxY2uttBrO15B0J1FR0otgDHjb5vDOPbvcSmvyOiP6j6WIdCxLjh9J+Tsp PQsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :cc:mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=4IUi00/hD+T9ne+TvaBRA7nb3ACxRSnXsg/JdhrT7BA=; b=vH2EOfxEtpTQgnfEomswxg0wivfpfLVRydl7772x3kSVcTHnpG+msV/PUfOnZ0CHbS PblvWNa9iL3qrhPXW405STR3ku1eXzgJPVrvVHq/F2dE0KHDTi9i4SX+lCIumIFA8vd1 /fDkutOy1IB9anu3bXoyGUrnU3hZ0R99vKf6qb/s6qI04WOFtJXyzH59TTa2gJexDZGB UzI5+kS+J2LSzENrQ3vjRJLGWhwv2ZoxRIkNeD95pfYS2yMa/LXlwt3BkcYDx4FK8GKd OywLsgtB3RfQlprT/0zELe9xaVAoULPrrGovIqjzsBmiqMHPWEN/f52ohG9R/N3YwWRu ethg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id f9si3209858qtq.274.2019.01.22.11.36.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Jan 2019 11:36:08 -0800 (PST) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com 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 AAFB27F6B3; Tue, 22 Jan 2019 19:36:01 +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 0E4931019626; Tue, 22 Jan 2019 19:36:01 +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 742063F603; Tue, 22 Jan 2019 19:35:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x0MJZuca024863 for ; Tue, 22 Jan 2019 14:35:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6642B103BAAD; Tue, 22 Jan 2019 19:35:56 +0000 (UTC) Delivered-To: libvir-list@redhat.com Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5B9E11048111; Tue, 22 Jan 2019 19:35:53 +0000 (UTC) Received: from complete.lackof.org (complete.lackof.org [198.49.126.79]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4AC1C13A5C; Tue, 22 Jan 2019 19:35:51 +0000 (UTC) Received: from localhost (c-107-2-141-103.hsd1.co.comcast.net [107.2.141.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by complete.lackof.org (Postfix) with ESMTPSA id 8CA4733E0255; Tue, 22 Jan 2019 12:26:35 -0700 (MST) From: dann frazier To: libvir-list@redhat.com, Radoslaw Biernacki , Michal Privoznik Date: Tue, 22 Jan 2019 12:26:14 -0700 Message-Id: <20190122192615.9256-4-dann.frazier@canonical.com> In-Reply-To: <20190122192615.9256-1-dann.frazier@canonical.com> References: <20190122192615.9256-1-dann.frazier@canonical.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.100.2 at complete.lackof.org X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on complete.lackof.org X-Greylist: Delayed for 00:09:17 by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 22 Jan 2019 19:35:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 22 Jan 2019 19:35:51 +0000 (UTC) for IP:'198.49.126.79' DOMAIN:'complete.lackof.org' HELO:'complete.lackof.org' FROM:'dannf@dannf.org' RCPT:'' X-RedHat-Spam-Score: 0.001 (HEADER_FROM_DIFFERENT_DOMAINS) 198.49.126.79 complete.lackof.org 198.49.126.79 complete.lackof.org X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: laine@laine.org Subject: [libvirt] [PATCH v3 3/4] util: Fix for NULL dereference 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.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.25]); Tue, 22 Jan 2019 19:36:07 +0000 (UTC) From: Radoslaw Biernacki The device xml parser code does not set "model" while parsing
virDomainDefPtr def->nets[i]->model can be NULL while latter compares strings with STREQ instead of STREQ_NULLABLE. Fixes: ac47e4a6225 (qemu: replace "def->nets[i]" with "net" and "def->sounds[i]" with "sound") Fixes: c7fc151eec7 (qemu: assign virtio devices to PCIe slot when appropriate) Signed-off-by: Radoslaw Biernacki Reviewed-by: Michal Privoznik Signed-off-by: dann frazier --- src/qemu/qemu_domain_address.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) -- 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index bd6c4031e0..9e0b50d41e 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -230,10 +230,8 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def) for (i = 0; i < def->nnets; i++) { virDomainNetDefPtr net = def->nets[i]; - if (net->model && - STREQ(net->model, "spapr-vlan")) { + if (STREQ_NULLABLE(net->model, "spapr-vlan")) net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO; - } if (qemuDomainAssignSpaprVIOAddress(def, &net->info, VIO_ADDR_NET) < 0) goto cleanup; @@ -322,8 +320,7 @@ qemuDomainPrimeVirtioDeviceAddresses(virDomainDefPtr def, for (i = 0; i < def->nnets; i++) { virDomainNetDefPtr net = def->nets[i]; - if (net->model && - STREQ(net->model, "virtio") && + if (STREQ_NULLABLE(net->model, "virtio") && net->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { net->info.type = type; } @@ -691,14 +688,14 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, * addresses for other hostdev devices. */ if (net->type == VIR_DOMAIN_NET_TYPE_HOSTDEV || - STREQ(net->model, "usb-net")) { + STREQ_NULLABLE(net->model, "usb-net")) { return 0; } - if (STREQ(net->model, "virtio")) + if (STREQ_NULLABLE(net->model, "virtio")) return virtioFlags; - if (STREQ(net->model, "e1000e")) + if (STREQ_NULLABLE(net->model, "e1000e")) return pcieFlags; return pciFlags;