diff mbox series

[1/6] cifs: fix status checks in cifs_tree_connect

Message ID 20230609174659.60327-1-sprasad@microsoft.com (mailing list archive)
State New, archived
Headers show
Series [1/6] cifs: fix status checks in cifs_tree_connect | expand

Commit Message

Shyam Prasad N June 9, 2023, 5:46 p.m. UTC
The ordering of status checks at the beginning of
cifs_tree_connect is wrong. As a result, a tcon
which is good may stay marked as needing reconnect
infinitely.

Fixes: 2f0e4f034220 ("cifs: check only tcon status on tcon related functions")
Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
---
 fs/smb/client/connect.c | 9 +++++----
 fs/smb/client/dfs.c     | 9 +++++----
 2 files changed, 10 insertions(+), 8 deletions(-)

Comments

Steve French June 10, 2023, 7:45 p.m. UTC | #1
tentatively merged into cifs-2.6.git for-next

On Fri, Jun 9, 2023 at 12:47 PM Shyam Prasad N <nspmangalore@gmail.com> wrote:
>
> The ordering of status checks at the beginning of
> cifs_tree_connect is wrong. As a result, a tcon
> which is good may stay marked as needing reconnect
> infinitely.
>
> Fixes: 2f0e4f034220 ("cifs: check only tcon status on tcon related functions")
> Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
> ---
>  fs/smb/client/connect.c | 9 +++++----
>  fs/smb/client/dfs.c     | 9 +++++----
>  2 files changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c
> index 8e9a672320ab..1250d156619b 100644
> --- a/fs/smb/client/connect.c
> +++ b/fs/smb/client/connect.c
> @@ -4086,16 +4086,17 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru
>
>         /* only send once per connect */
>         spin_lock(&tcon->tc_lock);
> +       if (tcon->status == TID_GOOD) {
> +               spin_unlock(&tcon->tc_lock);
> +               return 0;
> +       }
> +
>         if (tcon->status != TID_NEW &&
>             tcon->status != TID_NEED_TCON) {
>                 spin_unlock(&tcon->tc_lock);
>                 return -EHOSTDOWN;
>         }
>
> -       if (tcon->status == TID_GOOD) {
> -               spin_unlock(&tcon->tc_lock);
> -               return 0;
> -       }
>         tcon->status = TID_IN_TCON;
>         spin_unlock(&tcon->tc_lock);
>
> diff --git a/fs/smb/client/dfs.c b/fs/smb/client/dfs.c
> index 2f93bf8c3325..2390b2fedd6a 100644
> --- a/fs/smb/client/dfs.c
> +++ b/fs/smb/client/dfs.c
> @@ -575,16 +575,17 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru
>
>         /* only send once per connect */
>         spin_lock(&tcon->tc_lock);
> +       if (tcon->status == TID_GOOD) {
> +               spin_unlock(&tcon->tc_lock);
> +               return 0;
> +       }
> +
>         if (tcon->status != TID_NEW &&
>             tcon->status != TID_NEED_TCON) {
>                 spin_unlock(&tcon->tc_lock);
>                 return -EHOSTDOWN;
>         }
>
> -       if (tcon->status == TID_GOOD) {
> -               spin_unlock(&tcon->tc_lock);
> -               return 0;
> -       }
>         tcon->status = TID_IN_TCON;
>         spin_unlock(&tcon->tc_lock);
>
> --
> 2.34.1
>
diff mbox series

Patch

diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c
index 8e9a672320ab..1250d156619b 100644
--- a/fs/smb/client/connect.c
+++ b/fs/smb/client/connect.c
@@ -4086,16 +4086,17 @@  int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru
 
 	/* only send once per connect */
 	spin_lock(&tcon->tc_lock);
+	if (tcon->status == TID_GOOD) {
+		spin_unlock(&tcon->tc_lock);
+		return 0;
+	}
+
 	if (tcon->status != TID_NEW &&
 	    tcon->status != TID_NEED_TCON) {
 		spin_unlock(&tcon->tc_lock);
 		return -EHOSTDOWN;
 	}
 
-	if (tcon->status == TID_GOOD) {
-		spin_unlock(&tcon->tc_lock);
-		return 0;
-	}
 	tcon->status = TID_IN_TCON;
 	spin_unlock(&tcon->tc_lock);
 
diff --git a/fs/smb/client/dfs.c b/fs/smb/client/dfs.c
index 2f93bf8c3325..2390b2fedd6a 100644
--- a/fs/smb/client/dfs.c
+++ b/fs/smb/client/dfs.c
@@ -575,16 +575,17 @@  int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru
 
 	/* only send once per connect */
 	spin_lock(&tcon->tc_lock);
+	if (tcon->status == TID_GOOD) {
+		spin_unlock(&tcon->tc_lock);
+		return 0;
+	}
+
 	if (tcon->status != TID_NEW &&
 	    tcon->status != TID_NEED_TCON) {
 		spin_unlock(&tcon->tc_lock);
 		return -EHOSTDOWN;
 	}
 
-	if (tcon->status == TID_GOOD) {
-		spin_unlock(&tcon->tc_lock);
-		return 0;
-	}
 	tcon->status = TID_IN_TCON;
 	spin_unlock(&tcon->tc_lock);