]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commit
network: Resolve Coverity FORWARD_NULL
authorJohn Ferlan <jferlan@redhat.com>
Mon, 16 Mar 2015 12:50:11 +0000 (08:50 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 18 Mar 2015 10:56:24 +0000 (06:56 -0400)
commit0e3c68acd83a11045a6a9606636809084e16ce73
tree42c7b4a971ca9b5bb5675c5c1d2d76d989680d1a
parent18441ab914459cd4439a578aa3c8d667697393ee
network: Resolve Coverity FORWARD_NULL

The following is a long winded way to say this patch is avoiding a
false positive.

Coverity complains that calling networkPlugBandwidth() could eventually
end up with a NULL dereference on iface->bandwidth because in the
networkAllocateActualDevice there's a check of 'iface->bandwidth'
before deciding to try to use the 'portgroup' if it exists or to not
perferm the virNetDevBandwidthCopy if 'bandwidth' is not NULL.

Later in networkPlugBandwidth the 'iface->bandwidth' is sourced from
virDomainNetGetActualBandwidth - which would be either iface->bandwidth
or (preferably) iface->data.network.actual->bandwidth which would have
been filled in from either 'iface->bandwidth' or 'portgroup->bandwidth'
back in networkAllocateActualDevice

There *is* a check in networkCheckBandwidth for the result of the
virDomainNetGetActualBandwidth being NULL and a return 1 based on
that which would cause networkPlugBandwidth to exit properly and thus
never hit the condition that Coverity complains about.

However, since Coverity checks all paths - it somehow believes that
a return of 0 by networkCheckBandwidth in this condition would end
up causing the possible NULL dereference. The "fix" to silence Coverity
is to not have networkCheckBandwidth also call virDomainNetGetActualBandwidth
in order to get the ifaceBand, but rather have it accept it as an argument
which causes Coverity to "see" that it's the exit condition of 1 that won't
have the possible NULL dereference.  Since we're passing that, I added the
passing of iface->mac rather than passing iface as well. This just hopefully
makes sure someone doesn't undo this in the future...
src/network/bridge_driver.c