From patchwork Sat Nov 17 19:51:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Radoslaw Biernacki X-Patchwork-Id: 151419 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp855052ljp; Sat, 17 Nov 2018 12:01:29 -0800 (PST) X-Google-Smtp-Source: AJdET5fAcSroflDQO/VGWIG+9LG335xNjxnWuILF/IBkr4v5tGciryIhLl3MdPM0K3Fv/BInns4g X-Received: by 2002:a37:6801:: with SMTP id d1mr14990878qkc.217.1542484889159; Sat, 17 Nov 2018 12:01:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542484889; cv=none; d=google.com; s=arc-20160816; b=XR+TShwUQIw+Uf6HmHJKJukP0DHW0n0lT9+D7/I4TtIcAuKUWdFbysXNgjpMtd1RVW nGiDzWUnkAUuQ1mAzeaVE/S7yFJEo1dQREJwfiWo+kBmtr+1AXnzKleZCqOgRdTM8Sa1 WMJV62S4posPmeangUgoFQJP3IN7P/1qxWJLhZkK++w74if+xz3CfdnSF4hdw029RIWF h1u625ERQRS+yZ3IqAS1vQSn52wkH0o8s247XCkKvgbRQ/WW/9+nDxbAaYKC2QPNxLSA nmCc72fcEqp/G2tWUojNm3gGSwE1L+aqM8QLQVqFlfHqEiGUCg09cU0swTdRJQ7rIpzT fWcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=afujdvFQRQrZ9VFeV/B0ilFD5Umr8sqVVg/xx6sIjVc=; b=J2fEB8+8BJp1VQj59ckn6RRyooO0jTCZlduBBaT9vn12j+w3fQaILFuyghl9e9IH9E 2R4aChqwipeRjdaN1uhhKKfWI4oPhMaKcUMa1F7eV1XEmcQxkO2PGJoXITmjj7ADVyW5 0YcLmlgXSUwRsJne4OyxWDSMJpVmXd0Nf4xGRbBzYXWbZk6qup7R/GvT7aqt4iA6V4jg OaxDxhHlqpU4Gg8zxRwEobYTpUuxTXDMKp2Ijz4RsT+OYM47MGtoMJz7hjXFEoXbV2Xf IdsDamA9mS4l7OrA5vX6Hp/D7+ndAq9+xU0xs2hEHz96IhBujAGbvqVaIjUU8Fp7YXKK 87Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=LvaQBUSv; 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=linaro.org Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id i92si503753qtd.247.2018.11.17.12.01.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Nov 2018 12:01:29 -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; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=LvaQBUSv; 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=linaro.org Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E661385362; Sat, 17 Nov 2018 20:01:26 +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 5A15E7D2C8; Sat, 17 Nov 2018 20:01:26 +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 14EE2181B9E1; Sat, 17 Nov 2018 20:01:25 +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 wAHJpQYo029222 for ; Sat, 17 Nov 2018 14:51:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id 39514101962A; Sat, 17 Nov 2018 19:51:26 +0000 (UTC) Delivered-To: libvir-list@redhat.com Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 318A41001F3D for ; Sat, 17 Nov 2018 19:51:24 +0000 (UTC) Received: from mail-ed1-f68.google.com (mail-ed1-f68.google.com [209.85.208.68]) (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 D52E13084217 for ; Sat, 17 Nov 2018 19:51:22 +0000 (UTC) Received: by mail-ed1-f68.google.com with SMTP id f4so9586484edq.10 for ; Sat, 17 Nov 2018 11:51:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PxzE0LVPiDRRkOraSl4MU1fXKtt0B1+bjHE0+zgQilM=; b=LvaQBUSvO28rJ3PwODc40Q6vkOzG+IcLK2qGiFDUKHhp/kBDEDFsXwBtsl+jZLaM4E s0Ss2/niwKxxNbAJzvckfzA6ium455RtNTIhmd7MGwYpsOLFwFn5dTVf0gbFAj8dlnx6 JUtTChyA1vXpOdFgioZBQf5dMHGwDjpZFgTFg= 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; bh=PxzE0LVPiDRRkOraSl4MU1fXKtt0B1+bjHE0+zgQilM=; b=SekShAPO6bPHCiiaLo5AD03t/aiFdyN2NJd9Ui8z8aIMtrkyJztsv7Bz84WXiFjyPa c+Jhn1Zxy9hYjkFK5/DiVktH7+T3t4fH0tMfrDKXM1lftVQ/iCJgD/jeq24oVNLWA004 ntj2UbPbYV7tpDNcgoAk/5xEsSgo0HNR+fNLzsQTDGEi/8yLQtEYZxgtj7J9V6ZkJnCF ZF/ORo5WDHKCqmqUe5xPJijvKTJny+EP5mD0kiUuUc5LdDYtMKPrwN2hO8HtNFCzgQgm zgZnPRkVw2xX80RRlm7Dqynoj1y89n+dVG8a6giJWu+N5Ubq8O/FM9X8Y9AyfVwmoTBb qtNQ== X-Gm-Message-State: AGRZ1gLeiY2VtR80QdaN+M6a6sPeR/6Su/6eJc02mncrevGy2CYFqdp9 f+wrEL4xUFmzOKUODPiCZOWHzG48mVM= X-Received: by 2002:a17:906:3389:: with SMTP id v9-v6mr11975026eja.201.1542484281110; Sat, 17 Nov 2018 11:51:21 -0800 (PST) Received: from rad-H81M-S1.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id s12sm7887633edb.43.2018.11.17.11.51.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Nov 2018 11:51:20 -0800 (PST) From: Radoslaw Biernacki To: libvir-list@redhat.com, mprivozn@redhat.com Date: Sat, 17 Nov 2018 20:51:12 +0100 Message-Id: <20181117195113.12544-4-radoslaw.biernacki@linaro.org> In-Reply-To: <20181117195113.12544-1-radoslaw.biernacki@linaro.org> References: <20181110125624.1168-1-radoslaw.biernacki@linaro.org> <20181117195113.12544-1-radoslaw.biernacki@linaro.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Sat, 17 Nov 2018 19:51:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Sat, 17 Nov 2018 19:51:23 +0000 (UTC) for IP:'209.85.208.68' DOMAIN:'mail-ed1-f68.google.com' HELO:'mail-ed1-f68.google.com' FROM:'radoslaw.biernacki@linaro.org' RCPT:'' X-RedHat-Spam-Score: -0.112 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.208.68 mail-ed1-f68.google.com 209.85.208.68 mail-ed1-f68.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.40 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: laine@laine.org Subject: [libvirt] [PATCH v2 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: , MIME-Version: 1.0 Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Sat, 17 Nov 2018 20:01:27 +0000 (UTC) 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 --- src/qemu/qemu_domain_address.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) -- 2.14.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 73ed9cc68c..f9275ed810 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -232,10 +232,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; @@ -324,8 +322,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; } @@ -692,14 +689,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;