Skip to content

Commit 449a68c

Browse files
Lai Jiangshanpaulmck
authored andcommitted
security,rcu: Convert call_rcu(sel_netport_free) to kfree_rcu()
The rcu callback sel_netport_free() just calls a kfree(), so we use kfree_rcu() instead of the call_rcu(sel_netport_free). Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Stephen Smalley <sds@tycho.nsa.gov> Cc: James Morris <jmorris@namei.org> Cc: Eric Paris <eparis@parisplace.org> Reviewed-by: Josh Triplett <josh@joshtriplett.org>
1 parent 9801c60 commit 449a68c

1 file changed

Lines changed: 2 additions & 18 deletions

File tree

‎security/selinux/netport.c‎

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,22 +67,6 @@ static LIST_HEAD(sel_netport_list);
6767
static DEFINE_SPINLOCK(sel_netport_lock);
6868
static struct sel_netport_bkt sel_netport_hash[SEL_NETPORT_HASH_SIZE];
6969

70-
/**
71-
* sel_netport_free - Frees a port entry
72-
* @p: the entry's RCU field
73-
*
74-
* Description:
75-
* This function is designed to be used as a callback to the call_rcu()
76-
* function so that memory allocated to a hash table port entry can be
77-
* released safely.
78-
*
79-
*/
80-
static void sel_netport_free(struct rcu_head *p)
81-
{
82-
struct sel_netport *port = container_of(p, struct sel_netport, rcu);
83-
kfree(port);
84-
}
85-
8670
/**
8771
* sel_netport_hashfn - Hashing function for the port table
8872
* @pnum: port number
@@ -142,7 +126,7 @@ static void sel_netport_insert(struct sel_netport *port)
142126
rcu_dereference(sel_netport_hash[idx].list.prev),
143127
struct sel_netport, list);
144128
list_del_rcu(&tail->list);
145-
call_rcu(&tail->rcu, sel_netport_free);
129+
kfree_rcu(tail, rcu);
146130
} else
147131
sel_netport_hash[idx].size++;
148132
}
@@ -241,7 +225,7 @@ static void sel_netport_flush(void)
241225
list_for_each_entry_safe(port, port_tmp,
242226
&sel_netport_hash[idx].list, list) {
243227
list_del_rcu(&port->list);
244-
call_rcu(&port->rcu, sel_netport_free);
228+
kfree_rcu(port, rcu);
245229
}
246230
sel_netport_hash[idx].size = 0;
247231
}

0 commit comments

Comments
 (0)