security,rcu: Convert call_rcu(sel_netnode_free) to kfree_rcu()
The rcu callback sel_netnode_free() just calls a kfree(), so we use kfree_rcu() instead of the call_rcu(sel_netnode_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>
This commit is contained in:
committed by
Paul E. McKenney
parent
f218a7ee7a
commit
9801c60e99
@@ -68,22 +68,6 @@ static LIST_HEAD(sel_netnode_list);
|
|||||||
static DEFINE_SPINLOCK(sel_netnode_lock);
|
static DEFINE_SPINLOCK(sel_netnode_lock);
|
||||||
static struct sel_netnode_bkt sel_netnode_hash[SEL_NETNODE_HASH_SIZE];
|
static struct sel_netnode_bkt sel_netnode_hash[SEL_NETNODE_HASH_SIZE];
|
||||||
|
|
||||||
/**
|
|
||||||
* sel_netnode_free - Frees a node entry
|
|
||||||
* @p: the entry's RCU field
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* This function is designed to be used as a callback to the call_rcu()
|
|
||||||
* function so that memory allocated to a hash table node entry can be
|
|
||||||
* released safely.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static void sel_netnode_free(struct rcu_head *p)
|
|
||||||
{
|
|
||||||
struct sel_netnode *node = container_of(p, struct sel_netnode, rcu);
|
|
||||||
kfree(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sel_netnode_hashfn_ipv4 - IPv4 hashing function for the node table
|
* sel_netnode_hashfn_ipv4 - IPv4 hashing function for the node table
|
||||||
* @addr: IPv4 address
|
* @addr: IPv4 address
|
||||||
@@ -193,7 +177,7 @@ static void sel_netnode_insert(struct sel_netnode *node)
|
|||||||
rcu_dereference(sel_netnode_hash[idx].list.prev),
|
rcu_dereference(sel_netnode_hash[idx].list.prev),
|
||||||
struct sel_netnode, list);
|
struct sel_netnode, list);
|
||||||
list_del_rcu(&tail->list);
|
list_del_rcu(&tail->list);
|
||||||
call_rcu(&tail->rcu, sel_netnode_free);
|
kfree_rcu(tail, rcu);
|
||||||
} else
|
} else
|
||||||
sel_netnode_hash[idx].size++;
|
sel_netnode_hash[idx].size++;
|
||||||
}
|
}
|
||||||
@@ -306,7 +290,7 @@ static void sel_netnode_flush(void)
|
|||||||
list_for_each_entry_safe(node, node_tmp,
|
list_for_each_entry_safe(node, node_tmp,
|
||||||
&sel_netnode_hash[idx].list, list) {
|
&sel_netnode_hash[idx].list, list) {
|
||||||
list_del_rcu(&node->list);
|
list_del_rcu(&node->list);
|
||||||
call_rcu(&node->rcu, sel_netnode_free);
|
kfree_rcu(node, rcu);
|
||||||
}
|
}
|
||||||
sel_netnode_hash[idx].size = 0;
|
sel_netnode_hash[idx].size = 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user