Merge tag 'net-next-6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev...
[platform/kernel/linux-starfive.git] / net / sunrpc / svcsock.c
index 9d9f522..e43f263 100644 (file)
@@ -826,12 +826,6 @@ static void svc_tcp_listen_data_ready(struct sock *sk)
 
        trace_sk_data_ready(sk);
 
-       if (svsk) {
-               /* Refer to svc_setup_socket() for details. */
-               rmb();
-               svsk->sk_odata(sk);
-       }
-
        /*
         * This callback may called twice when a new connection
         * is established as a child socket inherits everything
@@ -840,13 +834,18 @@ static void svc_tcp_listen_data_ready(struct sock *sk)
         *    when one of child sockets become ESTABLISHED.
         * 2) data_ready method of the child socket may be called
         *    when it receives data before the socket is accepted.
-        * In case of 2, we should ignore it silently.
+        * In case of 2, we should ignore it silently and DO NOT
+        * dereference svsk.
         */
-       if (sk->sk_state == TCP_LISTEN) {
-               if (svsk) {
-                       set_bit(XPT_CONN, &svsk->sk_xprt.xpt_flags);
-                       svc_xprt_enqueue(&svsk->sk_xprt);
-               }
+       if (sk->sk_state != TCP_LISTEN)
+               return;
+
+       if (svsk) {
+               /* Refer to svc_setup_socket() for details. */
+               rmb();
+               svsk->sk_odata(sk);
+               set_bit(XPT_CONN, &svsk->sk_xprt.xpt_flags);
+               svc_xprt_enqueue(&svsk->sk_xprt);
        }
 }
 
@@ -887,13 +886,8 @@ static struct svc_xprt *svc_tcp_accept(struct svc_xprt *xprt)
        clear_bit(XPT_CONN, &svsk->sk_xprt.xpt_flags);
        err = kernel_accept(sock, &newsock, O_NONBLOCK);
        if (err < 0) {
-               if (err == -ENOMEM)
-                       printk(KERN_WARNING "%s: no more sockets!\n",
-                              serv->sv_name);
-               else if (err != -EAGAIN)
-                       net_warn_ratelimited("%s: accept failed (err %d)!\n",
-                                            serv->sv_name, -err);
-               trace_svcsock_accept_err(xprt, serv->sv_name, err);
+               if (err != -EAGAIN)
+                       trace_svcsock_accept_err(xprt, serv->sv_name, err);
                return NULL;
        }
        if (IS_ERR(sock_alloc_file(newsock, O_NONBLOCK, NULL)))
@@ -1450,7 +1444,7 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv,
        svsk->sk_owspace = inet->sk_write_space;
        /*
         * This barrier is necessary in order to prevent race condition
-        * with svc_data_ready(), svc_listen_data_ready() and others
+        * with svc_data_ready(), svc_tcp_listen_data_ready(), and others
         * when calling callbacks above.
         */
        wmb();
@@ -1462,7 +1456,7 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv,
        else
                svc_tcp_init(svsk, serv);
 
-       trace_svcsock_new_socket(sock);
+       trace_svcsock_new(svsk, sock);
        return svsk;
 }
 
@@ -1643,6 +1637,8 @@ static void svc_sock_free(struct svc_xprt *xprt)
        struct svc_sock *svsk = container_of(xprt, struct svc_sock, sk_xprt);
        struct socket *sock = svsk->sk_sock;
 
+       trace_svcsock_free(svsk, sock);
+
        tls_handshake_cancel(sock->sk);
        if (sock->file)
                sockfd_put(sock);