OpenVZ Forum


Home » Mailing lists » Devel » [PATCH 4/7] cgroup: fix memory leak in cgroup_get_sb()
[PATCH 4/7] cgroup: fix memory leak in cgroup_get_sb() [message #27506] Mon, 18 February 2008 05:49 Go to next message
Li Zefan is currently offline  Li Zefan
Messages: 90
Registered: February 2008
Member
opts.release_agent is not kfree()ed in all necessary places.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 kernel/cgroup.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 0c35022..aa76bbd 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -961,8 +961,11 @@ static int cgroup_get_sb(struct file_system_type *fs_type,
 	}
 
 	root = kzalloc(sizeof(*root), GFP_KERNEL);
-	if (!root)
+	if (!root) {
+		if (opts.release_agent)
+			kfree(opts.release_agent);
 		return -ENOMEM;
+	}
 
 	init_cgroup_root(root);
 	root->subsys_bits = opts.subsys_bits;
-- 
1.5.4.rc3

_______________________________________________
Containers mailing list
Containers@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers
Re: [PATCH 4/7] cgroup: fix memory leak in cgroup_get_sb() [message #27578 is a reply to message #27506] Wed, 20 February 2008 03:04 Go to previous message
Paul Menage is currently offline  Paul Menage
Messages: 642
Registered: September 2006
Senior Member
On Feb 17, 2008 9:49 PM, Li Zefan <lizf@cn.fujitsu.com> wrote:
> opts.release_agent is not kfree()ed in all necessary places.
>
> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>

Acked-by: Paul Menage <menage@google.com>

Good catch, although hopefully something that would be extremely rare
in practice.

Thanks,

Paul

> ---
>  kernel/cgroup.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> index 0c35022..aa76bbd 100644
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -961,8 +961,11 @@ static int cgroup_get_sb(struct file_system_type *fs_type,
>         }
>
>         root = kzalloc(sizeof(*root), GFP_KERNEL);
> -       if (!root)
> +       if (!root) {
> +               if (opts.release_agent)
> +                       kfree(opts.release_agent);
>                 return -ENOMEM;
> +       }
>
>         init_cgroup_root(root);
>         root->subsys_bits = opts.subsys_bits;
> --
> 1.5.4.rc3
>
>
_______________________________________________
Containers mailing list
Containers@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers
Previous Topic: [PATCH 6/7] cgroup: remove duplicate code in find_css_set()
Next Topic: Re: [PATCH 1/7] cgroup: fix and update documentation
Goto Forum:
  


Current Time: Thu Jul 18 07:42:24 GMT 2024

Total time taken to generate the page: 0.02572 seconds