Message ID | 20220827181314.193710-1-xiyou.wangcong@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 8fc29ff3910f3af08a7c40a75d436b5720efe2bf |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net,v2] kcm: fix strp_init() order and cleanup | expand |
Hello: This patch was applied to netdev/net.git (master) by Jakub Kicinski <kuba@kernel.org>: On Sat, 27 Aug 2022 11:13:14 -0700 you wrote: > From: Cong Wang <cong.wang@bytedance.com> > > strp_init() is called just a few lines above this csk->sk_user_data > check, it also initializes strp->work etc., therefore, it is > unnecessary to call strp_done() to cancel the freshly initialized > work. > > [...] Here is the summary with links: - [net,v2] kcm: fix strp_init() order and cleanup https://git.kernel.org/netdev/net/c/8fc29ff3910f You are awesome, thank you!
diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c index 71899e5a5a11..1215c863e1c4 100644 --- a/net/kcm/kcmsock.c +++ b/net/kcm/kcmsock.c @@ -1412,12 +1412,6 @@ static int kcm_attach(struct socket *sock, struct socket *csock, psock->sk = csk; psock->bpf_prog = prog; - err = strp_init(&psock->strp, csk, &cb); - if (err) { - kmem_cache_free(kcm_psockp, psock); - goto out; - } - write_lock_bh(&csk->sk_callback_lock); /* Check if sk_user_data is already by KCM or someone else. @@ -1425,13 +1419,18 @@ static int kcm_attach(struct socket *sock, struct socket *csock, */ if (csk->sk_user_data) { write_unlock_bh(&csk->sk_callback_lock); - strp_stop(&psock->strp); - strp_done(&psock->strp); kmem_cache_free(kcm_psockp, psock); err = -EALREADY; goto out; } + err = strp_init(&psock->strp, csk, &cb); + if (err) { + write_unlock_bh(&csk->sk_callback_lock); + kmem_cache_free(kcm_psockp, psock); + goto out; + } + psock->save_data_ready = csk->sk_data_ready; psock->save_write_space = csk->sk_write_space; psock->save_state_change = csk->sk_state_change;