From patchwork Sat Nov 10 12:56:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Radoslaw Biernacki X-Patchwork-Id: 150733 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1026661ljp; Sat, 10 Nov 2018 05:04:59 -0800 (PST) X-Google-Smtp-Source: AJdET5daZdeYHPRscrBKIBPHbjlkI4L5koxk6FOlj8nOdon50E4MUx0GVkxcuRsEQNNNc7KCJeRU X-Received: by 2002:ac8:6949:: with SMTP id n9mr5753402qtr.308.1541855099668; Sat, 10 Nov 2018 05:04:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541855099; cv=none; d=google.com; s=arc-20160816; b=L8LqSkOH+kO/W2okoIycH9ilskhANvtnLFvP/+kDF0Fyy+H2Fn9s2hrMCjFlV64BMk t8rtwruFEACwPUJEOf54BA45WXnOIH1k53cgggVEDxPF2kpZnqAyUoEDJqYyr3xhv0Si G8uBnMkDaI3OFoobSZz0xXO6uujX4WQmZJZz8ZcKHFct3YAPf5IZUVaCUgXWW9zvymLe IbxaNmqDIAvzFRmwoRStEEkgfK2v7Ts7zA7UTR2NZfBxNHPzTCVbzNGBXmYvU0QUO12I EV1D+pmO7vCklc1J0LoWgqDLKWdDQGYO1Mwv1GOUGFyuz074v/FD+4VAltVxZZD8wyP9 Bo+Q== 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=CtrxUGPa6icLSFVNwnk0vse0VI75oFNO4KlsNpguOwU=; b=Iaq0wuv9bD3Kp1DtF5sTqYPlp+dvakJN/IkovrtxnygAR8Hx96scn9ku60pNKCyjwa wr2I3eavD1ReUVdFeCXrSodR0LQFFQoQj5NclIaTuUAqX8RyaAS7VeyIKskpnefQeSEO u+4K5xwCGgF3TAKbGwWYWBLyAxqd9T4H96Yx3MWd79M2yQOQ3CEkWjT1TzXChd6TugX7 rqEgd+2ij6h+UPkvl9jOy3oeAsSMvsluGJ+G7CzSKmJZ13pbhi127gAEu9UdhB9ltrtQ /txld6yH9EaH8aIMC8dRLSS6/fpDbkIfD3PfZMWgCzXV3p2bpo50AQCtnfklcA5Fb4CH f8Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=BHLgzVCg; 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 u38si1922042qtk.133.2018.11.10.05.04.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 10 Nov 2018 05:04:59 -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=BHLgzVCg; 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-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F1898811DC; Sat, 10 Nov 2018 13:04:56 +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 5483216D5C; Sat, 10 Nov 2018 13:04:55 +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 A2135180053A; Sat, 10 Nov 2018 13:04:51 +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 wAACugfG022807 for ; Sat, 10 Nov 2018 07:56:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7F2D2103BAB9; Sat, 10 Nov 2018 12:56:42 +0000 (UTC) Delivered-To: libvir-list@redhat.com Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 73AE7100194B for ; Sat, 10 Nov 2018 12:56:40 +0000 (UTC) Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) (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 075F587621 for ; Sat, 10 Nov 2018 12:56:39 +0000 (UTC) Received: by mail-lj1-f195.google.com with SMTP id e5-v6so3862868lja.4 for ; Sat, 10 Nov 2018 04:56:38 -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=EHR3I5uR6aRXZVSs7m0yqZL63sA3kQ6MEBnS9JX8js8=; b=BHLgzVCgQ0724dDhs17rfj6J1RsiCb7dI7G7Ts3Yd2wnD2ppgNNdzLS9PHl9f4vzXF iZBI8VcBKXair4Htl7SGujJePtB2qu09Jt51MhwLEVJetZF3xUwBw1azO8cnvampIg6i /gKwIkfL+qeiHrk9B2HfgUg00U92n+Thd3VGY= 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=EHR3I5uR6aRXZVSs7m0yqZL63sA3kQ6MEBnS9JX8js8=; b=bJ0MYXQEYUe14lS4fBzXH/I4IYx9aTOyWRWtkcBLwhL+9SSPzl6rBGKR4U/vh9exJI SUhOBCsbu2obY4xBVfxO/5ZCRLCN/l5WxkukW1hrSeoeMVUPqoV9c5cba5F/jioDl1xf aXVMvynXpj6lw27TBqtKbfdwr3lfoXalRKvX6SVfe2pzhWWKuDoVfGrKt/mH/AEn0/Qw HMdCq0AO97tl4RFYwhx/ND1PRXr+isTRzjdzmvCbmaWWNwkWqzn31h2KBPWfSHbw5wrA 64OTvRMRFZGh7/jZ4ZJX3yGaBwp8UbL8LJrKIG0/tzEt1PYqVJB3Xd4bsi3qKdwnhM31 q1Ww== X-Gm-Message-State: AGRZ1gIzq9gHTCT8x52V2qYTs9hZEMFLuL9pi8jSSqYXPQaZ8aGHcF7x kdoCEPwojMg56QRjZ+PE9kIg178tW7U= X-Received: by 2002:a2e:82c9:: with SMTP id n9-v6mr7516900ljh.137.1541854597098; Sat, 10 Nov 2018 04:56:37 -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 h16-v6sm2145024lfc.0.2018.11.10.04.56.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 10 Nov 2018 04:56:36 -0800 (PST) From: Radoslaw Biernacki To: libvir-list@redhat.com Date: Sat, 10 Nov 2018 13:56:23 +0100 Message-Id: <20181110125624.1168-4-radoslaw.biernacki@linaro.org> In-Reply-To: <20181110125624.1168-1-radoslaw.biernacki@linaro.org> References: <20181110125624.1168-1-radoslaw.biernacki@linaro.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Sat, 10 Nov 2018 12:56:39 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Sat, 10 Nov 2018 12:56:39 +0000 (UTC) for IP:'209.85.208.195' DOMAIN:'mail-lj1-f195.google.com' HELO:'mail-lj1-f195.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.195 mail-lj1-f195.google.com 209.85.208.195 mail-lj1-f195.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: laine@laine.org Subject: [libvirt] [PATCH 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sat, 10 Nov 2018 13:04:58 +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 --- src/qemu/qemu_domain_address.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 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 27c9bfb946..15d25481d8 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -232,8 +232,7 @@ 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; } @@ -325,7 +324,7 @@ qemuDomainPrimeVirtioDeviceAddresses(virDomainDefPtr def, virDomainNetDefPtr net = def->nets[i]; if (net->model && - STREQ(net->model, "virtio") && + STREQ_NULLABLE(net->model, "virtio") && net->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { net->info.type = type; } @@ -634,14 +633,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;