提交 8fac64db 编写于 作者: R Radoslaw Biernacki 提交者: Michal Privoznik

util: Fix for NULL dereference

The device xml parser code does not set "model" while parsing the
following XML:

  <interface type='hostdev'>
    <source>
      <address type='pci' domain='0x0002' bus='0x01' slot='0x00' function='0x2'/>
    </source>
  </interface>

The net->model can be NULL and therefore must be compared using
STREQ_NULLABLE instead of plain STREQ.

Fixes: ac47e4a6 (qemu: replace "def->nets[i]" with "net" and "def->sounds[i]" with "sound")
Fixes: c7fc151e (qemu: assign virtio devices to PCIe slot when appropriate)
Signed-off-by: NRadoslaw Biernacki <radoslaw.biernacki@linaro.org>
Signed-off-by: Ndann frazier <dann.frazier@canonical.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 10bca495
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册