Skip to content

Commit f04a703

Browse files
Matthew Wilcoxsmfrench
authored andcommitted
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 <[email protected]> Signed-off-by: Steve French <[email protected]> CC: Stable <[email protected]>
1 parent d8ec913 commit f04a703

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

fs/cifs/file.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3471,20 +3471,18 @@ static const struct vm_operations_struct cifs_file_vm_ops = {
34713471

34723472
int cifs_file_strict_mmap(struct file *file, struct vm_area_struct *vma)
34733473
{
3474-
int rc, xid;
3474+
int xid, rc = 0;
34753475
struct inode *inode = file_inode(file);
34763476

34773477
xid = get_xid();
34783478

3479-
if (!CIFS_CACHE_READ(CIFS_I(inode))) {
3479+
if (!CIFS_CACHE_READ(CIFS_I(inode)))
34803480
rc = cifs_zap_mapping(inode);
3481-
if (rc)
3482-
return rc;
3483-
}
3484-
3485-
rc = generic_file_mmap(file, vma);
3486-
if (rc == 0)
3481+
if (!rc)
3482+
rc = generic_file_mmap(file, vma);
3483+
if (!rc)
34873484
vma->vm_ops = &cifs_file_vm_ops;
3485+
34883486
free_xid(xid);
34893487
return rc;
34903488
}
@@ -3494,16 +3492,16 @@ int cifs_file_mmap(struct file *file, struct vm_area_struct *vma)
34943492
int rc, xid;
34953493

34963494
xid = get_xid();
3495+
34973496
rc = cifs_revalidate_file(file);
3498-
if (rc) {
3497+
if (rc)
34993498
cifs_dbg(FYI, "Validation prior to mmap failed, error=%d\n",
35003499
rc);
3501-
free_xid(xid);
3502-
return rc;
3503-
}
3504-
rc = generic_file_mmap(file, vma);
3505-
if (rc == 0)
3500+
if (!rc)
3501+
rc = generic_file_mmap(file, vma);
3502+
if (!rc)
35063503
vma->vm_ops = &cifs_file_vm_ops;
3504+
35073505
free_xid(xid);
35083506
return rc;
35093507
}

0 commit comments

Comments
 (0)