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

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



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 cn fujitsu com>
---
  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


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