cgroup: make cgroup_addrm_files() clean up after itself on failures
authorTejun Heo <tj@kernel.org>
Fri, 18 Sep 2015 21:54:23 +0000 (17:54 -0400)
committerTejun Heo <tj@kernel.org>
Fri, 18 Sep 2015 21:54:23 +0000 (17:54 -0400)
commit6732ed853af942ba20ddbd091336acc7df569119
treed9ed138eceaa11e3f8ae8d34c9496e6ef5d9c98f
parentccdca2187b03decd186df13e44c57fbf1974d0a0
cgroup: make cgroup_addrm_files() clean up after itself on failures

After a file creation failure, cgroup_addrm_files() it didn't remove
the files which had already been created.  When cgroup_populate_dir()
is the caller, this is fine as the caller performs cleanup; however,
for other callers, this may leave unactivated dangling files behind.
As kernfs directory removals are recursive, this doesn't lead to
permanent memory leak but it can, for example, fail future attempts to
create those files again.

There's no point in keeping around this sort of subtlety and it gets
in the way of planned updates to file handling.  This patch makes
cgroup_addrm_files() clean up after itself on failures.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
kernel/cgroup.c