[libvirt] [PATCH 7/7] nwfilter: Alter virNWFilterSnoopReqLeaseDel logic

John Ferlan jferlan at redhat.com
Fri Sep 28 15:28:10 UTC 2018


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 at redhat.com>
---
 src/nwfilter/nwfilter_dhcpsnoop.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c
index 6d114557c7..e40f649ed5 100644
--- a/src/nwfilter/nwfilter_dhcpsnoop.c
+++ b/src/nwfilter/nwfilter_dhcpsnoop.c
@@ -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);
-- 
2.17.1




More information about the libvir-list mailing list