qemu_hotplug: Don't dereference NULL pointer @newb in qemuDomainChangeNet()

In one of my previous commits I've made an attempt to restore the
noqueue qdisc on a TAP corresponding to domain's <interface/> if
QoS is cleared out. The commit consisted of two almost identical
hunks. In both the pointer is dereferenced. But in one of them,
the pointer to new bandwidth can't be NULL while in the other it
can leading to a crash.

Fixes: d53b092353
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1919619
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
Michal Privoznik 2021-02-15 18:30:41 +01:00
parent 97f99b4bd4
commit a1229335f6

View File

@ -3900,10 +3900,10 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
/* If the old bandwidth was cleared out, restore qdisc. */
if (virDomainNetTypeSharesHostView(newdev)) {
if (!newb->out || newb->out->average == 0)
if (!newb || !newb->out || newb->out->average == 0)
qemuDomainInterfaceSetDefaultQDisc(driver, newdev);
} else {
if (!newb->in || newb->in->average == 0)
if (!newb || !newb->in || newb->in->average == 0)
qemuDomainInterfaceSetDefaultQDisc(driver, newdev);
}
needReplaceDevDef = true;