[PATCH] interface: fix udev reference leak with invalid flags

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

 



The udevInterfaceGetXMLDesc method takes a reference on the udev
driver as its first action. If the virCheckFlags() condition
fails, however, this reference is never released.

Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
---
 src/interface/interface_backend_udev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/interface/interface_backend_udev.c b/src/interface/interface_backend_udev.c
index fdf11a8318..e1a50389c9 100644
--- a/src/interface/interface_backend_udev.c
+++ b/src/interface/interface_backend_udev.c
@@ -1027,12 +1027,14 @@ static char *
 udevInterfaceGetXMLDesc(virInterfacePtr ifinfo,
                         unsigned int flags)
 {
-    struct udev *udev = udev_ref(driver->udev);
+    struct udev *udev = NULL;
     g_autoptr(virInterfaceDef) ifacedef = NULL;
     char *xmlstr = NULL;
 
     virCheckFlags(VIR_INTERFACE_XML_INACTIVE, NULL);
 
+    udev = udev_ref(driver->udev);
+
     /* Recursively build up the interface XML based on the requested
      * interface name
      */
-- 
2.45.1




[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