]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
nwfilter: Alter virNWFilterSnoopReqLeaseDel logic
authorJohn Ferlan <jferlan@redhat.com>
Fri, 28 Sep 2018 00:36:58 +0000 (20:36 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 1 Oct 2018 18:27:47 +0000 (14:27 -0400)
Move the fetch of @ipAddrLeft to after the goto skip_instantiate
and remove the (req->binding) guard since we know that as long
as req->binding is created, then req->threadkey is filled in.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
src/nwfilter/nwfilter_dhcpsnoop.c

index 6d114557c71a0bf462f905af72f0dfa0b24c0a90..e40f649ed56ba5be42dd26d54b6c654ac44dff23 100644 (file)
@@ -846,7 +846,6 @@ virNWFilterSnoopReqLeaseDel(virNWFilterSnoopReqPtr req,
     int ret = 0;
     virNWFilterSnoopIPLeasePtr ipl;
     char *ipstr = NULL;
-    int ipAddrLeft = 0;
 
     /* protect req->start, req->ifname and the lease */
     virNWFilterSnoopReqLock(req);
@@ -867,13 +866,13 @@ virNWFilterSnoopReqLeaseDel(virNWFilterSnoopReqPtr req,
     if (update_leasefile)
         virNWFilterSnoopLeaseFileSave(ipl);
 
-    if (req->binding)
-        ipAddrLeft = virNWFilterIPAddrMapDelIPAddr(req->binding->portdevname, ipstr);
-
     if (!req->threadkey || !instantiate)
         goto skip_instantiate;
 
-    if (ipAddrLeft) {
+    /* Assumes that req->binding is valid since req->threadkey
+     * is only generated after req->binding is filled in during
+     * virNWFilterDHCPSnoopReq processing */
+    if ((virNWFilterIPAddrMapDelIPAddr(req->binding->portdevname, ipstr)) > 0) {
         ret = virNWFilterInstantiateFilterLate(req->driver,
                                                req->binding,
                                                req->ifindex);