Commit ee6858f7 authored by Matthew Wilcox's avatar Matthew Wilcox Committed by Greg Kroah-Hartman

cifs: Fix missing put_xid in cifs_file_strict_mmap

commit f04a703c upstream.

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: default avatarMatthew Wilcox <mawilcox@microsoft.com>
Signed-off-by: default avatarSteve French <smfrench@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ba4f9c19
...@@ -3285,20 +3285,18 @@ static const struct vm_operations_struct cifs_file_vm_ops = { ...@@ -3285,20 +3285,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 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); struct inode *inode = file_inode(file);
xid = get_xid(); xid = get_xid();
if (!CIFS_CACHE_READ(CIFS_I(inode))) { if (!CIFS_CACHE_READ(CIFS_I(inode)))
rc = cifs_zap_mapping(inode); rc = cifs_zap_mapping(inode);
if (rc) if (!rc)
return rc; rc = generic_file_mmap(file, vma);
} if (!rc)
rc = generic_file_mmap(file, vma);
if (rc == 0)
vma->vm_ops = &cifs_file_vm_ops; vma->vm_ops = &cifs_file_vm_ops;
free_xid(xid); free_xid(xid);
return rc; return rc;
} }
...@@ -3308,16 +3306,16 @@ int cifs_file_mmap(struct file *file, struct vm_area_struct *vma) ...@@ -3308,16 +3306,16 @@ int cifs_file_mmap(struct file *file, struct vm_area_struct *vma)
int rc, xid; int rc, xid;
xid = get_xid(); xid = get_xid();
rc = cifs_revalidate_file(file); rc = cifs_revalidate_file(file);
if (rc) { if (rc)
cifs_dbg(FYI, "Validation prior to mmap failed, error=%d\n", cifs_dbg(FYI, "Validation prior to mmap failed, error=%d\n",
rc); rc);
free_xid(xid); if (!rc)
return rc; rc = generic_file_mmap(file, vma);
} if (!rc)
rc = generic_file_mmap(file, vma);
if (rc == 0)
vma->vm_ops = &cifs_file_vm_ops; vma->vm_ops = &cifs_file_vm_ops;
free_xid(xid); free_xid(xid);
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment