Commit 36553434f475a84b653e25e74490ee8df43b86d5
Committed by
Linus Torvalds
1 parent
5a3eb9f6b7
Exists in
master
and in
4 other branches
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>
Showing 1 changed file with 12 additions and 18 deletions Side-by-side Diff
kernel/cgroup.c
... | ... | @@ -355,6 +355,17 @@ |
355 | 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 | 370 | * allocate_cg_links() allocates "count" cg_cgroup_link structures |
360 | 371 | * and chains them on tmp through their cgrp_link_list fields. Returns 0 on |
361 | 372 | |
... | ... | @@ -363,17 +374,12 @@ |
363 | 374 | static int allocate_cg_links(int count, struct list_head *tmp) |
364 | 375 | { |
365 | 376 | struct cg_cgroup_link *link; |
366 | - struct cg_cgroup_link *saved_link; | |
367 | 377 | int i; |
368 | 378 | INIT_LIST_HEAD(tmp); |
369 | 379 | for (i = 0; i < count; i++) { |
370 | 380 | link = kmalloc(sizeof(*link), GFP_KERNEL); |
371 | 381 | if (!link) { |
372 | - list_for_each_entry_safe(link, saved_link, tmp, | |
373 | - cgrp_link_list) { | |
374 | - list_del(&link->cgrp_link_list); | |
375 | - kfree(link); | |
376 | - } | |
382 | + free_cg_links(tmp); | |
377 | 383 | return -ENOMEM; |
378 | 384 | } |
379 | 385 | list_add(&link->cgrp_link_list, tmp); |
... | ... | @@ -381,17 +387,6 @@ |
381 | 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 | 391 | * find_css_set() takes an existing cgroup group and a |
397 | 392 | * cgroup object, and returns a css_set object that's |
... | ... | @@ -956,7 +951,6 @@ |
956 | 951 | struct super_block *sb; |
957 | 952 | struct cgroupfs_root *root; |
958 | 953 | struct list_head tmp_cg_links; |
959 | - INIT_LIST_HEAD(&tmp_cg_links); | |
960 | 954 | |
961 | 955 | /* First find the desired set of subsystems */ |
962 | 956 | ret = parse_cgroupfs_options(data, &opts); |