drm/amd/display: Add NULL test for 'timing generator' in 'dcn21_set_pipe()'
[platform/kernel/linux-starfive.git] / io_uring / net.c
index 7a8e298..75d494d 100644 (file)
@@ -1461,16 +1461,6 @@ int io_connect(struct io_kiocb *req, unsigned int issue_flags)
        int ret;
        bool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;
 
-       if (connect->in_progress) {
-               struct socket *socket;
-
-               ret = -ENOTSOCK;
-               socket = sock_from_file(req->file);
-               if (socket)
-                       ret = sock_error(socket->sk);
-               goto out;
-       }
-
        if (req_has_async_data(req)) {
                io = req->async_data;
        } else {
@@ -1490,9 +1480,7 @@ int io_connect(struct io_kiocb *req, unsigned int issue_flags)
            && force_nonblock) {
                if (ret == -EINPROGRESS) {
                        connect->in_progress = true;
-                       return -EAGAIN;
-               }
-               if (ret == -ECONNABORTED) {
+               } else if (ret == -ECONNABORTED) {
                        if (connect->seen_econnaborted)
                                goto out;
                        connect->seen_econnaborted = true;
@@ -1506,6 +1494,16 @@ int io_connect(struct io_kiocb *req, unsigned int issue_flags)
                memcpy(req->async_data, &__io, sizeof(__io));
                return -EAGAIN;
        }
+       if (connect->in_progress) {
+               /*
+                * At least bluetooth will return -EBADFD on a re-connect
+                * attempt, and it's (supposedly) also valid to get -EISCONN
+                * which means the previous result is good. For both of these,
+                * grab the sock_error() and use that for the completion.
+                */
+               if (ret == -EBADFD || ret == -EISCONN)
+                       ret = sock_error(sock_from_file(req->file)->sk);
+       }
        if (ret == -ERESTARTSYS)
                ret = -EINTR;
 out: