cifs: Fix missing put_xid in cifs_file_strict_mmap
authorMatthew Wilcox <mawilcox@microsoft.com>
Fri, 15 Dec 2017 20:48:32 +0000 (12:48 -0800)
committerSteve French <smfrench@gmail.com>
Thu, 25 Jan 2018 01:49:06 +0000 (19:49 -0600)
If cifs_zap_mapping() returned an error, we would return without putting
the xid that we got earlier.  Restructure cifs_file_strict_mmap() and
cifs_file_mmap() to be more similar to each other and have a single
point of return that always puts the xid.

Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
Signed-off-by: Steve French <smfrench@gmail.com>
CC: Stable <stable@vger.kernel.org>
fs/cifs/file.c

index df9f682708c6a6f4e17ea308c26f972ad48599e8..3a85df2a9baf22301b139b09c522a0f4fa3428cc 100644 (file)
@@ -3471,20 +3471,18 @@ static const struct vm_operations_struct cifs_file_vm_ops = {
 
 int cifs_file_strict_mmap(struct file *file, struct vm_area_struct *vma)
 {
-       int rc, xid;
+       int xid, rc = 0;
        struct inode *inode = file_inode(file);
 
        xid = get_xid();
 
-       if (!CIFS_CACHE_READ(CIFS_I(inode))) {
+       if (!CIFS_CACHE_READ(CIFS_I(inode)))
                rc = cifs_zap_mapping(inode);
-               if (rc)
-                       return rc;
-       }
-
-       rc = generic_file_mmap(file, vma);
-       if (rc == 0)
+       if (!rc)
+               rc = generic_file_mmap(file, vma);
+       if (!rc)
                vma->vm_ops = &cifs_file_vm_ops;
+
        free_xid(xid);
        return rc;
 }
@@ -3494,16 +3492,16 @@ int cifs_file_mmap(struct file *file, struct vm_area_struct *vma)
        int rc, xid;
 
        xid = get_xid();
+
        rc = cifs_revalidate_file(file);
-       if (rc) {
+       if (rc)
                cifs_dbg(FYI, "Validation prior to mmap failed, error=%d\n",
                         rc);
-               free_xid(xid);
-               return rc;
-       }
-       rc = generic_file_mmap(file, vma);
-       if (rc == 0)
+       if (!rc)
+               rc = generic_file_mmap(file, vma);
+       if (!rc)
                vma->vm_ops = &cifs_file_vm_ops;
+
        free_xid(xid);
        return rc;
 }