summaryrefslogtreecommitdiffstats
path: root/fs/cifs/file.c
diff options
context:
space:
mode:
authorMatthew Wilcox <mawilcox@microsoft.com>2017-12-15 15:48:32 -0500
committerSteve French <smfrench@gmail.com>2018-01-24 20:49:06 -0500
commitf04a703c3d613845ae3141bfaf223489de8ab3eb (patch)
tree12d5c5ec922757e37040ab164b5dd50d2b6f400f /fs/cifs/file.c
parentd8ec913b178156661c2b941f94ec22487225d3dc (diff)
cifs: Fix missing put_xid in cifs_file_strict_mmap
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>
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r--fs/cifs/file.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index df9f682708c6..3a85df2a9baf 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -3471,20 +3471,18 @@ static const struct vm_operations_struct cifs_file_vm_ops = {
3471 3471
3472int cifs_file_strict_mmap(struct file *file, struct vm_area_struct *vma) 3472int cifs_file_strict_mmap(struct file *file, struct vm_area_struct *vma)
3473{ 3473{
3474 int rc, xid; 3474 int xid, rc = 0;
3475 struct inode *inode = file_inode(file); 3475 struct inode *inode = file_inode(file);
3476 3476
3477 xid = get_xid(); 3477 xid = get_xid();
3478 3478
3479 if (!CIFS_CACHE_READ(CIFS_I(inode))) { 3479 if (!CIFS_CACHE_READ(CIFS_I(inode)))
3480 rc = cifs_zap_mapping(inode); 3480 rc = cifs_zap_mapping(inode);
3481 if (rc) 3481 if (!rc)
3482 return rc; 3482 rc = generic_file_mmap(file, vma);
3483 } 3483 if (!rc)
3484
3485 rc = generic_file_mmap(file, vma);
3486 if (rc == 0)
3487 vma->vm_ops = &cifs_file_vm_ops; 3484 vma->vm_ops = &cifs_file_vm_ops;
3485
3488 free_xid(xid); 3486 free_xid(xid);
3489 return rc; 3487 return rc;
3490} 3488}
@@ -3494,16 +3492,16 @@ int cifs_file_mmap(struct file *file, struct vm_area_struct *vma)
3494 int rc, xid; 3492 int rc, xid;
3495 3493
3496 xid = get_xid(); 3494 xid = get_xid();
3495
3497 rc = cifs_revalidate_file(file); 3496 rc = cifs_revalidate_file(file);
3498 if (rc) { 3497 if (rc)
3499 cifs_dbg(FYI, "Validation prior to mmap failed, error=%d\n", 3498 cifs_dbg(FYI, "Validation prior to mmap failed, error=%d\n",
3500 rc); 3499 rc);
3501 free_xid(xid); 3500 if (!rc)
3502 return rc; 3501 rc = generic_file_mmap(file, vma);
3503 } 3502 if (!rc)
3504 rc = generic_file_mmap(file, vma);
3505 if (rc == 0)
3506 vma->vm_ops = &cifs_file_vm_ops; 3503 vma->vm_ops = &cifs_file_vm_ops;
3504
3507 free_xid(xid); 3505 free_xid(xid);
3508 return rc; 3506 return rc;
3509} 3507}