summaryrefslogtreecommitdiff
path: root/security/device_cgroup.c
diff options
context:
space:
mode:
authorAristeu Rozanski <aris@redhat.com>2012-10-04 17:15:15 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-06 03:05:14 +0900
commit868539a3b671e0f736ddd11b67bf1dc3d8a5a921 (patch)
tree2c2c10e2983c40ffad02fb01d55fad6f4a6b3175 /security/device_cgroup.c
parent66b8ef67756b3051bf42a077a82c3c5c279caa5b (diff)
device_cgroup: introduce dev_whitelist_clean()
This function cleans all the items in a whitelist and will be used by the next patches. Signed-off-by: Aristeu Rozanski <aris@redhat.com> Cc: Tejun Heo <tj@kernel.org> Cc: Li Zefan <lizefan@huawei.com> Cc: James Morris <jmorris@namei.org> Cc: Pavel Emelyanov <xemul@openvz.org> Acked-by: Serge E. Hallyn <serge.hallyn@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'security/device_cgroup.c')
-rw-r--r--security/device_cgroup.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/security/device_cgroup.c b/security/device_cgroup.c
index e3ce02a00ffc..5b36b62e9ff4 100644
--- a/security/device_cgroup.c
+++ b/security/device_cgroup.c
@@ -154,6 +154,22 @@ remove:
}
}
+/**
+ * dev_whitelist_clean - frees all entries of the whitelist
+ * @dev_cgroup: dev_cgroup with the whitelist to be cleaned
+ *
+ * called under devcgroup_mutex
+ */
+static void dev_whitelist_clean(struct dev_cgroup *dev_cgroup)
+{
+ struct dev_whitelist_item *wh, *tmp;
+
+ list_for_each_entry_safe(wh, tmp, &dev_cgroup->whitelist, list) {
+ list_del(&wh->list);
+ kfree(wh);
+ }
+}
+
/*
* called from kernel/cgroup.c with cgroup_lock() held.
*/
@@ -200,13 +216,9 @@ static struct cgroup_subsys_state *devcgroup_create(struct cgroup *cgroup)
static void devcgroup_destroy(struct cgroup *cgroup)
{
struct dev_cgroup *dev_cgroup;
- struct dev_whitelist_item *wh, *tmp;
dev_cgroup = cgroup_to_devcgroup(cgroup);
- list_for_each_entry_safe(wh, tmp, &dev_cgroup->whitelist, list) {
- list_del(&wh->list);
- kfree(wh);
- }
+ dev_whitelist_clean(dev_cgroup);
kfree(dev_cgroup);
}