hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/net/sunrpc/svcsock.c
....@@ -692,12 +692,6 @@
692692 {
693693 struct svc_sock *svsk = (struct svc_sock *)sk->sk_user_data;
694694
695
- if (svsk) {
696
- /* Refer to svc_setup_socket() for details. */
697
- rmb();
698
- svsk->sk_odata(sk);
699
- }
700
-
701695 /*
702696 * This callback may called twice when a new connection
703697 * is established as a child socket inherits everything
....@@ -706,13 +700,18 @@
706700 * when one of child sockets become ESTABLISHED.
707701 * 2) data_ready method of the child socket may be called
708702 * when it receives data before the socket is accepted.
709
- * In case of 2, we should ignore it silently.
703
+ * In case of 2, we should ignore it silently and DO NOT
704
+ * dereference svsk.
710705 */
711
- if (sk->sk_state == TCP_LISTEN) {
712
- if (svsk) {
713
- set_bit(XPT_CONN, &svsk->sk_xprt.xpt_flags);
714
- svc_xprt_enqueue(&svsk->sk_xprt);
715
- }
706
+ if (sk->sk_state != TCP_LISTEN)
707
+ return;
708
+
709
+ if (svsk) {
710
+ /* Refer to svc_setup_socket() for details. */
711
+ rmb();
712
+ svsk->sk_odata(sk);
713
+ set_bit(XPT_CONN, &svsk->sk_xprt.xpt_flags);
714
+ svc_xprt_enqueue(&svsk->sk_xprt);
716715 }
717716 }
718717