]> xenbits.xensource.com Git - libvirt.git/commitdiff
lxc_container: Resolve Coverity RESOURCE_LEAK
authorWang Rui <moon.wangrui@huawei.com>
Mon, 1 Sep 2014 12:08:08 +0000 (20:08 +0800)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 3 Sep 2014 19:01:11 +0000 (15:01 -0400)
Memory is allocated for 'mnt_src' by VIR_STRDUP in the loop. Next
loop it will be allocated again. So we need to free 'mnt_src'
before continue the loop.

Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
src/lxc/lxc_container.c

index 1cf2c8f38dfb9d5f0a3bff1b87af9bb6f5363590..33d705b76a0672cb362d59ce36d055f1717d6f18 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008-2013 Red Hat, Inc.
+ * Copyright (C) 2008-2014 Red Hat, Inc.
  * Copyright (C) 2008 IBM Corp.
  *
  * lxc_container.c: file description
@@ -886,12 +886,14 @@ static int lxcContainerMountBasicFS(bool userns_enabled,
             if (ret == 0) {
                 VIR_DEBUG("Skipping '%s' which isn't mounted in host",
                           mnt->dst);
+                VIR_FREE(mnt_src);
                 continue;
             }
         }
 
         if (mnt->skipUserNS && userns_enabled) {
             VIR_DEBUG("Skipping due to user ns enablement");
+            VIR_FREE(mnt_src);
             continue;
         }
 
@@ -930,6 +932,8 @@ static int lxcContainerMountBasicFS(bool userns_enabled,
                                  MS_BIND|MS_REMOUNT|MS_RDONLY);
             goto cleanup;
         }
+
+        VIR_FREE(mnt_src);
     }
 
     rc = 0;