]> xenbits.xensource.com Git - libvirt.git/commitdiff
sanlock: avoid leak in acquire()
authorMartin Kletzander <mkletzan@redhat.com>
Tue, 13 May 2014 11:40:38 +0000 (13:40 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Tue, 13 May 2014 11:50:57 +0000 (13:50 +0200)
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
src/locking/lock_driver_sanlock.c

index b3d31bf05b713b4077c57a72f51ed260991018a2..d0339a6df14d4d613493fb5eedb4b1d866b4bdb7 100644 (file)
@@ -907,9 +907,6 @@ static int virLockManagerSanlockAcquire(virLockManagerPtr lock,
         return -1;
     }
 
-    if (VIR_ALLOC(opt) < 0)
-        return -1;
-
     /* We only initialize 'sock' if we are in the real
      * child process and we need it to be inherited
      *
@@ -944,6 +941,9 @@ static int virLockManagerSanlockAcquire(virLockManagerPtr lock,
         return 0;
     }
 
+    if (VIR_ALLOC(opt) < 0)
+        goto error;
+
     /* sanlock doesn't use owner_name for anything, so it's safe to take just
      * the first SANLK_NAME_LEN - 1 characters from vm_name */
     ignore_value(virStrncpy(opt->owner_name, priv->vm_name,