Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 449a68cc authored by Lai Jiangshan's avatar Lai Jiangshan Committed by Paul E. McKenney
Browse files

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: default avatarLai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: default avatarPaul 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: default avatarJosh Triplett <josh@joshtriplett.org>
parent 9801c60e
Loading
Loading
Loading
Loading
+2 −18
Original line number Original line Diff line number Diff line
@@ -67,22 +67,6 @@ static LIST_HEAD(sel_netport_list);
static DEFINE_SPINLOCK(sel_netport_lock);
static DEFINE_SPINLOCK(sel_netport_lock);
static struct sel_netport_bkt sel_netport_hash[SEL_NETPORT_HASH_SIZE];
static struct sel_netport_bkt sel_netport_hash[SEL_NETPORT_HASH_SIZE];


/**
 * sel_netport_free - Frees a port 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 port entry can be
 * released safely.
 *
 */
static void sel_netport_free(struct rcu_head *p)
{
	struct sel_netport *port = container_of(p, struct sel_netport, rcu);
	kfree(port);
}

/**
/**
 * sel_netport_hashfn - Hashing function for the port table
 * sel_netport_hashfn - Hashing function for the port table
 * @pnum: port number
 * @pnum: port number
@@ -142,7 +126,7 @@ static void sel_netport_insert(struct sel_netport *port)
			rcu_dereference(sel_netport_hash[idx].list.prev),
			rcu_dereference(sel_netport_hash[idx].list.prev),
			struct sel_netport, list);
			struct sel_netport, list);
		list_del_rcu(&tail->list);
		list_del_rcu(&tail->list);
		call_rcu(&tail->rcu, sel_netport_free);
		kfree_rcu(tail, rcu);
	} else
	} else
		sel_netport_hash[idx].size++;
		sel_netport_hash[idx].size++;
}
}
@@ -241,7 +225,7 @@ static void sel_netport_flush(void)
		list_for_each_entry_safe(port, port_tmp,
		list_for_each_entry_safe(port, port_tmp,
					 &sel_netport_hash[idx].list, list) {
					 &sel_netport_hash[idx].list, list) {
			list_del_rcu(&port->list);
			list_del_rcu(&port->list);
			call_rcu(&port->rcu, sel_netport_free);
			kfree_rcu(port, rcu);
		}
		}
		sel_netport_hash[idx].size = 0;
		sel_netport_hash[idx].size = 0;
	}
	}