From: Aristeu Rozanski Date: Fri, 7 Sep 2012 00:25:04 +0000 (+1000) Subject: device_cgroup: introduce dev_whitelist_clean() X-Git-Tag: next-20120911~1^2~32 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=e0ca425e7d0fb8cc57538c878868a0ed679cb6bd;p=karo-tx-linux.git 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 Cc: Tejun Heo Cc: Li Zefan Cc: James Morris Cc: Pavel Emelyanov Cc: Serge Hallyn Signed-off-by: Andrew Morton --- diff --git a/security/device_cgroup.c b/security/device_cgroup.c index 574acae77a7d..17271a742fdc 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); }