[PATCH 3/3] network: Check for QOS before blindly using it

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/network/bridge_driver.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 68bb916501..9c49c70564 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -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;
-- 
2.20.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux