diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2008-07-30 01:33:19 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-30 12:41:44 -0400 |
commit | 36553434f475a84b653e25e74490ee8df43b86d5 (patch) | |
tree | 869f827ebb4974674a26de22db6c15f122e63618 /kernel/cgroup.c | |
parent | 5a3eb9f6b7c598529f832b8baa6458ab1cbab2c6 (diff) |
cgroup: remove duplicate code in allocate_cg_link()
- just call free_cg_links() in allocate_cg_links()
- the list will get initialized in allocate_cg_links(), so don't init
it twice
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Cc: Paul Menage <menage@google.com>
Cc: Cedric Le Goater <clg@fr.ibm.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r-- | kernel/cgroup.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 28debe4e1488..249a517591b8 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -355,6 +355,17 @@ static struct css_set *find_existing_css_set( | |||
355 | return NULL; | 355 | return NULL; |
356 | } | 356 | } |
357 | 357 | ||
358 | static void free_cg_links(struct list_head *tmp) | ||
359 | { | ||
360 | struct cg_cgroup_link *link; | ||
361 | struct cg_cgroup_link *saved_link; | ||
362 | |||
363 | list_for_each_entry_safe(link, saved_link, tmp, cgrp_link_list) { | ||
364 | list_del(&link->cgrp_link_list); | ||
365 | kfree(link); | ||
366 | } | ||
367 | } | ||
368 | |||
358 | /* | 369 | /* |
359 | * allocate_cg_links() allocates "count" cg_cgroup_link structures | 370 | * allocate_cg_links() allocates "count" cg_cgroup_link structures |
360 | * and chains them on tmp through their cgrp_link_list fields. Returns 0 on | 371 | * and chains them on tmp through their cgrp_link_list fields. Returns 0 on |
@@ -363,17 +374,12 @@ static struct css_set *find_existing_css_set( | |||
363 | static int allocate_cg_links(int count, struct list_head *tmp) | 374 | static int allocate_cg_links(int count, struct list_head *tmp) |
364 | { | 375 | { |
365 | struct cg_cgroup_link *link; | 376 | struct cg_cgroup_link *link; |
366 | struct cg_cgroup_link *saved_link; | ||
367 | int i; | 377 | int i; |
368 | INIT_LIST_HEAD(tmp); | 378 | INIT_LIST_HEAD(tmp); |
369 | for (i = 0; i < count; i++) { | 379 | for (i = 0; i < count; i++) { |
370 | link = kmalloc(sizeof(*link), GFP_KERNEL); | 380 | link = kmalloc(sizeof(*link), GFP_KERNEL); |
371 | if (!link) { | 381 | if (!link) { |
372 | list_for_each_entry_safe(link, saved_link, tmp, | 382 | free_cg_links(tmp); |
373 | cgrp_link_list) { | ||
374 | list_del(&link->cgrp_link_list); | ||
375 | kfree(link); | ||
376 | } | ||
377 | return -ENOMEM; | 383 | return -ENOMEM; |
378 | } | 384 | } |
379 | list_add(&link->cgrp_link_list, tmp); | 385 | list_add(&link->cgrp_link_list, tmp); |
@@ -381,17 +387,6 @@ static int allocate_cg_links(int count, struct list_head *tmp) | |||
381 | return 0; | 387 | return 0; |
382 | } | 388 | } |
383 | 389 | ||
384 | static void free_cg_links(struct list_head *tmp) | ||
385 | { | ||
386 | struct cg_cgroup_link *link; | ||
387 | struct cg_cgroup_link *saved_link; | ||
388 | |||
389 | list_for_each_entry_safe(link, saved_link, tmp, cgrp_link_list) { | ||
390 | list_del(&link->cgrp_link_list); | ||
391 | kfree(link); | ||
392 | } | ||
393 | } | ||
394 | |||
395 | /* | 390 | /* |
396 | * find_css_set() takes an existing cgroup group and a | 391 | * find_css_set() takes an existing cgroup group and a |
397 | * cgroup object, and returns a css_set object that's | 392 | * cgroup object, and returns a css_set object that's |
@@ -956,7 +951,6 @@ static int cgroup_get_sb(struct file_system_type *fs_type, | |||
956 | struct super_block *sb; | 951 | struct super_block *sb; |
957 | struct cgroupfs_root *root; | 952 | struct cgroupfs_root *root; |
958 | struct list_head tmp_cg_links; | 953 | struct list_head tmp_cg_links; |
959 | INIT_LIST_HEAD(&tmp_cg_links); | ||
960 | 954 | ||
961 | /* First find the desired set of subsystems */ | 955 | /* First find the desired set of subsystems */ |
962 | ret = parse_cgroupfs_options(data, &opts); | 956 | ret = parse_cgroupfs_options(data, &opts); |