lkml.org 
[lkml]   [2013]   [Jan]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH v3 2/9] devcg: reorder device exception functions
In preparation for the next patch, reorder dev_exception_add() and
dev_exception_rm().

Cc: Tejun Heo <tj@kernel.org>
Cc: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Aristeu Rozanski <aris@redhat.com>

---
security/device_cgroup.c | 44 ++++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 22 deletions(-)

--- github.orig/security/device_cgroup.c 2013-01-29 11:49:14.739657516 -0500
+++ github/security/device_cgroup.c 2013-01-29 11:49:14.987661210 -0500
@@ -104,18 +104,14 @@ free_and_exit:
/*
* called under devcgroup_mutex
*/
-static int dev_exception_add(struct list_head *exceptions,
+static void dev_exception_rm(struct list_head *exceptions,
struct dev_exception_item *ex)
{
- struct dev_exception_item *excopy, *walk;
+ struct dev_exception_item *walk, *tmp;

lockdep_assert_held(&devcgroup_mutex);

- excopy = kmemdup(ex, sizeof(*ex), GFP_KERNEL);
- if (!excopy)
- return -ENOMEM;
-
- list_for_each_entry(walk, exceptions, list) {
+ list_for_each_entry_safe(walk, tmp, exceptions, list) {
if (walk->type != ex->type)
continue;
if (walk->major != ex->major)
@@ -123,27 +119,29 @@ static int dev_exception_add(struct list
if (walk->minor != ex->minor)
continue;

- walk->access |= ex->access;
- kfree(excopy);
- excopy = NULL;
+ walk->access &= ~ex->access;
+ if (!walk->access) {
+ list_del_rcu(&walk->list);
+ kfree_rcu(walk, rcu);
+ }
}
-
- if (excopy != NULL)
- list_add_tail_rcu(&excopy->list, exceptions);
- return 0;
}

/*
* called under devcgroup_mutex
*/
-static void dev_exception_rm(struct list_head *exceptions,
+static int dev_exception_add(struct list_head *exceptions,
struct dev_exception_item *ex)
{
- struct dev_exception_item *walk, *tmp;
+ struct dev_exception_item *excopy, *walk;

lockdep_assert_held(&devcgroup_mutex);

- list_for_each_entry_safe(walk, tmp, exceptions, list) {
+ excopy = kmemdup(ex, sizeof(*ex), GFP_KERNEL);
+ if (!excopy)
+ return -ENOMEM;
+
+ list_for_each_entry(walk, exceptions, list) {
if (walk->type != ex->type)
continue;
if (walk->major != ex->major)
@@ -151,12 +149,14 @@ static void dev_exception_rm(struct list
if (walk->minor != ex->minor)
continue;

- walk->access &= ~ex->access;
- if (!walk->access) {
- list_del_rcu(&walk->list);
- kfree_rcu(walk, rcu);
- }
+ walk->access |= ex->access;
+ kfree(excopy);
+ excopy = NULL;
}
+
+ if (excopy != NULL)
+ list_add_tail_rcu(&excopy->list, exceptions);
+ return 0;
}

static void __dev_exception_clean(struct dev_cgroup *dev_cgroup)


\
 
 \ /
  Last update: 2013-01-29 21:01    [W:0.186 / U:1.676 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site