Fix match_prepath()
authorSachin Prabhu <sprabhu@redhat.com>
Wed, 26 Apr 2017 13:05:46 +0000 (14:05 +0100)
committerSteve French <smfrench@gmail.com>
Fri, 28 Apr 2017 12:54:54 +0000 (07:54 -0500)
Incorrect return value for shares not using the prefix path means that
we will never match superblocks for these shares.

Fixes: commit c1d8b24d1819 ("Compare prepaths when comparing superblocks")
Cc: stable@vger.kernel.org
Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
Signed-off-by: Steve French <smfrench@gmail.com>
fs/cifs/connect.c

index d82467cfb0e2df5ef7e655bc601f4f17f3b890b1..d95744d8b8abab549afa5cc6ed0b91c3ae51dc49 100644 (file)
@@ -2912,16 +2912,14 @@ match_prepath(struct super_block *sb, struct cifs_mnt_data *mnt_data)
 {
        struct cifs_sb_info *old = CIFS_SB(sb);
        struct cifs_sb_info *new = mnt_data->cifs_sb;
+       bool old_set = old->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH;
+       bool new_set = new->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH;
 
-       if (old->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH) {
-               if (!(new->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH))
-                       return 0;
-               /* The prepath should be null terminated strings */
-               if (strcmp(new->prepath, old->prepath))
-                       return 0;
-
+       if (old_set && new_set && !strcmp(new->prepath, old->prepath))
                return 1;
-       }
+       else if (!old_set && !new_set)
+               return 1;
+
        return 0;
 }