diff options
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r-- | kernel/cgroup.c | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 657f8f8d93a5..13932abde159 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); |
@@ -1424,14 +1418,17 @@ static ssize_t cgroup_write_string(struct cgroup *cgrp, struct cftype *cft, | |||
1424 | if (buffer == NULL) | 1418 | if (buffer == NULL) |
1425 | return -ENOMEM; | 1419 | return -ENOMEM; |
1426 | } | 1420 | } |
1427 | if (nbytes && copy_from_user(buffer, userbuf, nbytes)) | 1421 | if (nbytes && copy_from_user(buffer, userbuf, nbytes)) { |
1428 | return -EFAULT; | 1422 | retval = -EFAULT; |
1423 | goto out; | ||
1424 | } | ||
1429 | 1425 | ||
1430 | buffer[nbytes] = 0; /* nul-terminate */ | 1426 | buffer[nbytes] = 0; /* nul-terminate */ |
1431 | strstrip(buffer); | 1427 | strstrip(buffer); |
1432 | retval = cft->write_string(cgrp, cft, buffer); | 1428 | retval = cft->write_string(cgrp, cft, buffer); |
1433 | if (!retval) | 1429 | if (!retval) |
1434 | retval = nbytes; | 1430 | retval = nbytes; |
1431 | out: | ||
1435 | if (buffer != local_buffer) | 1432 | if (buffer != local_buffer) |
1436 | kfree(buffer); | 1433 | kfree(buffer); |
1437 | return retval; | 1434 | return retval; |
@@ -2371,7 +2368,7 @@ static int cgroup_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
2371 | return cgroup_create(c_parent, dentry, mode | S_IFDIR); | 2368 | return cgroup_create(c_parent, dentry, mode | S_IFDIR); |
2372 | } | 2369 | } |
2373 | 2370 | ||
2374 | static inline int cgroup_has_css_refs(struct cgroup *cgrp) | 2371 | static int cgroup_has_css_refs(struct cgroup *cgrp) |
2375 | { | 2372 | { |
2376 | /* Check the reference count on each subsystem. Since we | 2373 | /* Check the reference count on each subsystem. Since we |
2377 | * already established that there are no tasks in the | 2374 | * already established that there are no tasks in the |