Re: [PATCH 1/3] LXC: avoid useless memory free in lxcContainerIdentifyCGroups

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

 



On 2012年06月15日 15:41, Gao feng wrote:
when lxcContainerIdentifyCGroups failed, lxcContainerSetupPivortRoot
and lxcContainerSetupExtraMounts will free the memory that allocated
in lxcContainerIdentifyCGroups.

So we need not call lxcContainerCGroupFree when
lxcContainerIdentifyCGroups failed.

Signed-off-by: Gao feng<gaofeng@xxxxxxxxxxxxxx>
---
  src/lxc/lxc_container.c |    7 +++----
  1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 4fbceb4..87de463 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -1236,17 +1236,16 @@ static int lxcContainerIdentifyCGroups(struct lxcContainerCGroup **mountsret,
          }
      }

-    *mountsret = mounts;
-    *nmountsret = nmounts;
      ret = 0;

  cleanup:
+    *mountsret = mounts;
+    *nmountsret = nmounts;
+
      closedir(dh);
      endmntent(procmnt);
      VIR_FREE(path);

-    if (ret<  0)
-        lxcContainerCGroupFree(mounts, nmounts);
      return ret;
  }


NACK. Personally I think removing the duplicate free() in the callers
(only lxcContainerSetupPivortRoot and lxcContainerSetupExtraMounts
now) is better. No reason to keep an allocated memory while the function
itself fails.

Regards,
Osier

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