[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1293794758.2973.49.camel@edumazet-laptop>
Date: Fri, 31 Dec 2010 12:25:58 +0100
From: Eric Dumazet <eric.dumazet@...il.com>
To: stefani@...bold.net
Cc: linux-kernel@...r.kernel.org, akpm@...ux-foundation.org,
davem@...emloft.net, netdev@...r.kernel.org
Subject: Re: [PATCH] UDPCP Communication Protocol
Le vendredi 31 décembre 2010 à 10:29 +0100, stefani@...bold.net a
écrit :
> + if (!list_empty(&usk->destlist)) {
> + state->sk = (struct sock *)usk;
> + state->dest = list_first_entry(&usk->destlist,
> + struct udpcp_dest, list);
> + sock_hold(state->sk);
> +
> + if (atomic_read(&state->sk->sk_refcnt) != 1) {
> + spin_unlock_irqrestore(&spinlock, flags);
> + return state;
> + }
> + atomic_dec(&state->sk->sk_refcnt);
> + }
> +
I am trying to understand what you are doing here.
It seems racy to me.
Apparently, what you want is to take a reference only if actual
sk_refcnt is not zero.
I suggest using atomic_inc_notzero(&state->sk->sk_refcnt) to avoid the
race in atomic_dec().
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists