[libvirt] [PATCH v2] LXC: avoid useless duplicate memory free

when lxcContainerIdentifyCGroups failed, the memory it allocated has been freed, so we should not free this memory again in lxcContainerSetupPivortRoot and lxcContainerSetupExtraMounts. Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com> --- src/lxc/lxc_container.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 9045a7d..24b1017 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -1323,7 +1323,7 @@ static int lxcContainerSetupPivotRoot(virDomainDefPtr vmDef, /* Before pivoting we need to identify any * cgroups controllers that are mounted */ if (lxcContainerIdentifyCGroups(&mounts, &nmounts) < 0) - goto cleanup; + return -1; /* Gives us a private root, leaving all parent OS mounts on /.oldroot */ if (lxcContainerPivotRoot(root) < 0) @@ -1406,7 +1406,7 @@ static int lxcContainerSetupExtraMounts(virDomainDefPtr vmDef, /* Before replacing /sys we need to identify any * cgroups controllers that are mounted */ if (lxcContainerIdentifyCGroups(&mounts, &nmounts) < 0) - goto cleanup; + return -1; /* Gets rid of any existing stuff under /proc, since we need new * namespace aware versions of those. We must do /proc second -- 1.7.7.6

On 2012年06月19日 09:33, Gao feng wrote:
when lxcContainerIdentifyCGroups failed, the memory it allocated has been freed, so we should not free this memory again in lxcContainerSetupPivortRoot and lxcContainerSetupExtraMounts.
Signed-off-by: Gao feng<gaofeng@cn.fujitsu.com> --- src/lxc/lxc_container.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 9045a7d..24b1017 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -1323,7 +1323,7 @@ static int lxcContainerSetupPivotRoot(virDomainDefPtr vmDef, /* Before pivoting we need to identify any * cgroups controllers that are mounted */ if (lxcContainerIdentifyCGroups(&mounts,&nmounts)< 0) - goto cleanup; + return -1;
/* Gives us a private root, leaving all parent OS mounts on /.oldroot */ if (lxcContainerPivotRoot(root)< 0) @@ -1406,7 +1406,7 @@ static int lxcContainerSetupExtraMounts(virDomainDefPtr vmDef, /* Before replacing /sys we need to identify any * cgroups controllers that are mounted */ if (lxcContainerIdentifyCGroups(&mounts,&nmounts)< 0) - goto cleanup; + return -1;
/* Gets rid of any existing stuff under /proc, since we need new * namespace aware versions of those. We must do /proc second
ACK.

On 2012年06月19日 11:57, Osier Yang wrote:
On 2012年06月19日 09:33, Gao feng wrote:
when lxcContainerIdentifyCGroups failed, the memory it allocated has been freed, so we should not free this memory again in lxcContainerSetupPivortRoot and lxcContainerSetupExtraMounts.
Signed-off-by: Gao feng<gaofeng@cn.fujitsu.com> --- src/lxc/lxc_container.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 9045a7d..24b1017 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -1323,7 +1323,7 @@ static int lxcContainerSetupPivotRoot(virDomainDefPtr vmDef, /* Before pivoting we need to identify any * cgroups controllers that are mounted */ if (lxcContainerIdentifyCGroups(&mounts,&nmounts)< 0) - goto cleanup; + return -1;
/* Gives us a private root, leaving all parent OS mounts on /.oldroot */ if (lxcContainerPivotRoot(root)< 0) @@ -1406,7 +1406,7 @@ static int lxcContainerSetupExtraMounts(virDomainDefPtr vmDef, /* Before replacing /sys we need to identify any * cgroups controllers that are mounted */ if (lxcContainerIdentifyCGroups(&mounts,&nmounts)< 0) - goto cleanup; + return -1;
/* Gets rid of any existing stuff under /proc, since we need new * namespace aware versions of those. We must do /proc second
ACK.
Pushed.
participants (2)
-
Gao feng
-
Osier Yang