[libvirt] [PATCH] nwfilter: Remove redundant check if object exists

Pavel Hrdina posted 1 patch 5 years, 10 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/91ed30ae7512d2ec305471f82fcbd4226a00aee5.1530172406.git.phrdina@redhat.com
Test syntax-check passed
src/nwfilter/nwfilter_driver.c | 7 -------
1 file changed, 7 deletions(-)
[libvirt] [PATCH] nwfilter: Remove redundant check if object exists
Posted by Pavel Hrdina 5 years, 10 months ago
The same check is done by virNWFilterBindingObjListAdd().  The main
issue with the current code is that if the object already exists we
would leak 'def' because 'obj' would be set and the cleanup code frees
'def' only if 'obj' is NULL.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 src/nwfilter/nwfilter_driver.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index ed34586105..ac3a964388 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -752,13 +752,6 @@ nwfilterBindingCreateXML(virConnectPtr conn,
     if (virNWFilterBindingCreateXMLEnsureACL(conn, def) < 0)
         goto cleanup;
 
-    obj = virNWFilterBindingObjListFindByPortDev(driver->bindings, def->portdevname);
-    if (obj) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("Filter already present for NIC %s"), def->portdevname);
-        goto cleanup;
-    }
-
     obj = virNWFilterBindingObjListAdd(driver->bindings,
                                        def);
     if (!obj)
-- 
2.17.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] nwfilter: Remove redundant check if object exists
Posted by Daniel P. Berrangé 5 years, 10 months ago
On Thu, Jun 28, 2018 at 09:53:48AM +0200, Pavel Hrdina wrote:
> The same check is done by virNWFilterBindingObjListAdd().  The main
> issue with the current code is that if the object already exists we
> would leak 'def' because 'obj' would be set and the cleanup code frees
> 'def' only if 'obj' is NULL.
> 
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
>  src/nwfilter/nwfilter_driver.c | 7 -------
>  1 file changed, 7 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

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