[libvirt] [PATCH] cgroup.c: avoid unconditional leaks
Daniel P. Berrange
berrange at redhat.com
Thu Feb 4 13:36:31 UTC 2010
On Thu, Feb 04, 2010 at 11:16:53AM +0100, Jim Meyering wrote:
> Here's output from "git format-patch -U19 --stdout -1",
> so you see the context:
>
> >From 47ea9beecf93a796e606b4d906424c05e7f6c9bb Mon Sep 17 00:00:00 2001
> From: Jim Meyering <meyering at redhat.com>
> Date: Thu, 4 Feb 2010 11:14:03 +0100
> Subject: [PATCH] cgroup.c: avoid unconditional leaks
>
> * src/util/cgroup.c (virCgroupCpuSetInherit) [HAVE_MNTENT_H]:
> Don't leak CPU-set inheritance value strings.
> ---
> src/util/cgroup.c | 1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/src/util/cgroup.c b/src/util/cgroup.c
> index c80cf50..e6f0270 100644
> --- a/src/util/cgroup.c
> +++ b/src/util/cgroup.c
> @@ -416,38 +416,39 @@ static int virCgroupCpuSetInherit(virCgroupPtr parent, virCgroupPtr group)
> VIR_DEBUG("Setting up inheritance %s -> %s", parent->path, group->path);
> for (i = 0; i < ARRAY_CARDINALITY(inherit_values) ; i++) {
> char *value;
>
> rc = virCgroupGetValueStr(parent,
> VIR_CGROUP_CONTROLLER_CPUSET,
> inherit_values[i],
> &value);
> if (rc != 0) {
> VIR_ERROR("Failed to get %s %d", inherit_values[i], rc);
> break;
> }
>
> VIR_DEBUG("Inherit %s = %s", inherit_values[i], value);
>
> rc = virCgroupSetValueStr(group,
> VIR_CGROUP_CONTROLLER_CPUSET,
> inherit_values[i],
> value);
> + VIR_FREE(value);
>
> if (rc != 0) {
> VIR_ERROR("Failed to set %s %d", inherit_values[i], rc);
> break;
> }
> }
>
> return rc;
> }
>
> static int virCgroupMakeGroup(virCgroupPtr parent, virCgroupPtr group, int create)
> {
> int i;
> int rc = 0;
>
> VIR_DEBUG("Make group %s", group->path);
> for (i = 0 ; i < VIR_CGROUP_CONTROLLER_LAST ; i++) {
> char *path = NULL;
>
> --
ACK, that's an unusually large context that diff generated !
Daniel
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
More information about the libvir-list
mailing list