提交 f4db846c 编写于 作者: J John Ferlan

network: Check for QOS before blindly using it

If networkAllocatePort calls networkPlugBandwidth eventually the
port->bandwidth would be passed to virNetDevBandwidthPlug which
requires that the parameter is non-NULL.  Coverity additionally
notes that since (!port->bandwidth) is checked earlier in the
networkAllocatePort method that the subsequent call to blindly
use if for a function that requires it needs to check.
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
Reviewed-by: NDaniel Henrique Barboza <danielhb413@gmail.com>
上级 10881fac
......@@ -4567,6 +4567,13 @@ networkAllocatePort(virNetworkObjPtr obj,
return -1;
}
if (!port->bandwidth) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("QOS must be defined for network '%s'"),
netdef->name);
return -1;
}
if (networkPlugBandwidth(obj, &port->mac, port->bandwidth, &port->class_id) < 0)
return -1;
break;
......@@ -4633,6 +4640,13 @@ networkAllocatePort(virNetworkObjPtr obj,
}
}
if (!port->bandwidth) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("QOS must be defined for network '%s'"),
netdef->name);
return -1;
}
if (networkPlugBandwidth(obj, &port->mac, port->bandwidth, &port->class_id) < 0)
return -1;
break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册