From e506bd990d6ac567b3ce7fd32d5ce950f899df72 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 13 Aug 2013 18:37:45 +0000 Subject: [PATCH] fcst: Fix a race condition git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4961 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- fcst/ft_sess.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fcst/ft_sess.c b/fcst/ft_sess.c index a943a5b60..ed1687a7a 100644 --- a/fcst/ft_sess.c +++ b/fcst/ft_sess.c @@ -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;