fcst: Fix a race condition

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4961 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2013-08-13 18:37:45 +00:00
parent e41c3bf328
commit e506bd990d

View File

@@ -216,7 +216,8 @@ static struct ft_sess *ft_sess_get(struct fc_lport *lport, u32 port_id)
hlist_for_each_entry_rcu(sess, head, hash) {
#endif
if (sess->port_id == port_id) {
kref_get(&sess->kref);
if (!kref_get_unless_zero(&sess->kref))
sess = NULL;
rcu_read_unlock();
FT_SESS_DBG("port_id %x found %p\n", port_id, sess);
return sess;