Skip to contentSkip to conversation

cgroup: fix memory leak in cgroup_get_sb()

PATCH In review Li Zefan 3 participants 3 messages Feb 18, 2008 – Feb 20, 2008 1 message not in the archive

lore
Share & tools
lore

Li Zefan

author
#0 lore raw

PATCH 4/7 cgroup: fix memory leak in cgroup_get_sb()

opts.release_agent is not kfree()ed in all necessary places.

---
 kernel/cgroup.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
kernel/cgroup.c +4 -1
index 0c35022..aa76bbd 100644
@@ -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;
Signature · 1 line
1.5.4.rc3

A message that is not in the archive (sent off-list or not yet received): [email protected]

Acked-by
#2 lore raw
Quoted 3 lines · Li Zefan

opts.release_agent is not kfree()ed in all necessary places.

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

Thanks,

Paul

Quoted 25 lines
---
 kernel/cgroup.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
kernel/cgroup.c +4 -2
index 0c35022..aa76bbd 100644
@@ -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

Acked-by on v1 4/7
#3 lore raw
In reply to Li Zefan
Quoted 3 lines · Li Zefan

opts.release_agent is not kfree()ed in all necessary places.

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

Thanks,

Paul

Quoted 25 lines
---
 kernel/cgroup.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
kernel/cgroup.c +4 -2
index 0c35022..aa76bbd 100644
@@ -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