diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c
index b919db02c7f9e37a45074c40e3273682aa7b17b9..dd83837f0fbf0d9787c0e7c91daebd7399a569cd 100644
--- a/net/kcm/kcmsock.c
+++ b/net/kcm/kcmsock.c
@@ -1839,10 +1839,10 @@ static int kcm_release(struct socket *sock)
 	kcm = kcm_sk(sk);
 	mux = kcm->mux;
 
+	lock_sock(sk);
 	sock_orphan(sk);
 	kfree_skb(kcm->seq_skb);
 
-	lock_sock(sk);
 	/* Purge queue under lock to avoid race condition with tx_work trying
 	 * to act when queue is nonempty. If tx_work runs after this point
 	 * it will just return.