[PATCH] sanlock: fix memory leak

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

 



Detected by Coverity.  The only way to get to error_unlink is if
path was successfully assigned, so the if was useless.  Meanwhile,
there was a return statement that did not free path.

* src/locking/lock_driver_sanlock.c
(virLockManagerSanlockSetupLockspace): Fix mem-leak, and drop
useless if.
---
 src/locking/lock_driver_sanlock.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sanlock.c
index 2d72510..13940f1 100644
--- a/src/locking/lock_driver_sanlock.c
+++ b/src/locking/lock_driver_sanlock.c
@@ -239,7 +239,7 @@ static int virLockManagerSanlockSetupLockspace(void)
                 virReportSystemError(-rv,
                                      _("Unable to add lockspace %s"),
                                      path);
-            return -1;
+            goto error_unlink;
         } else {
             VIR_DEBUG("Lockspace %s is already registered", path);
         }
@@ -250,8 +250,7 @@ static int virLockManagerSanlockSetupLockspace(void)
     return 0;

 error_unlink:
-    if (path)
-        unlink(path);
+    unlink(path);
 error:
     VIR_FORCE_CLOSE(fd);
     VIR_FREE(path);
-- 
1.7.4.4

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


[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]