Skip to content

Commit 575e079

Browse files
z00467499smfrench
authored andcommitted
cifs: Fix xid leak in cifs_flock()
If not flock, before return -ENOLCK, should free the xid, otherwise, the xid will be leaked. Fixes: d067799 ("cifs: add support for flock") Reviewed-by: Paulo Alcantara (SUSE) <[email protected]> Signed-off-by: Zhang Xiaoxu <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 9a97df4 commit 575e079

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

fs/cifs/file.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,11 +1885,13 @@ int cifs_flock(struct file *file, int cmd, struct file_lock *fl)
18851885
struct cifsFileInfo *cfile;
18861886
__u32 type;
18871887

1888-
rc = -EACCES;
18891888
xid = get_xid();
18901889

1891-
if (!(fl->fl_flags & FL_FLOCK))
1892-
return -ENOLCK;
1890+
if (!(fl->fl_flags & FL_FLOCK)) {
1891+
rc = -ENOLCK;
1892+
free_xid(xid);
1893+
return rc;
1894+
}
18931895

18941896
cfile = (struct cifsFileInfo *)file->private_data;
18951897
tcon = tlink_tcon(cfile->tlink);
@@ -1908,8 +1910,9 @@ int cifs_flock(struct file *file, int cmd, struct file_lock *fl)
19081910
* if no lock or unlock then nothing to do since we do not
19091911
* know what it is
19101912
*/
1913+
rc = -EOPNOTSUPP;
19111914
free_xid(xid);
1912-
return -EOPNOTSUPP;
1915+
return rc;
19131916
}
19141917

19151918
rc = cifs_setlk(file, fl, type, wait_flag, posix_lck, lock, unlock,

0 commit comments

Comments
 (0)