Commit 575e079c authored by Zhang Xiaoxu's avatar Zhang Xiaoxu Committed by Steve French

cifs: Fix xid leak in cifs_flock()

If not flock, before return -ENOLCK, should free the xid,
otherwise, the xid will be leaked.

Fixes: d0677992 ("cifs: add support for flock")
Reviewed-by: default avatarPaulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: default avatarZhang Xiaoxu <zhangxiaoxu5@huawei.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 9a97df40
...@@ -1885,11 +1885,13 @@ int cifs_flock(struct file *file, int cmd, struct file_lock *fl) ...@@ -1885,11 +1885,13 @@ int cifs_flock(struct file *file, int cmd, struct file_lock *fl)
struct cifsFileInfo *cfile; struct cifsFileInfo *cfile;
__u32 type; __u32 type;
rc = -EACCES;
xid = get_xid(); xid = get_xid();
if (!(fl->fl_flags & FL_FLOCK)) if (!(fl->fl_flags & FL_FLOCK)) {
return -ENOLCK; rc = -ENOLCK;
free_xid(xid);
return rc;
}
cfile = (struct cifsFileInfo *)file->private_data; cfile = (struct cifsFileInfo *)file->private_data;
tcon = tlink_tcon(cfile->tlink); tcon = tlink_tcon(cfile->tlink);
...@@ -1908,8 +1910,9 @@ int cifs_flock(struct file *file, int cmd, struct file_lock *fl) ...@@ -1908,8 +1910,9 @@ int cifs_flock(struct file *file, int cmd, struct file_lock *fl)
* if no lock or unlock then nothing to do since we do not * if no lock or unlock then nothing to do since we do not
* know what it is * know what it is
*/ */
rc = -EOPNOTSUPP;
free_xid(xid); free_xid(xid);
return -EOPNOTSUPP; return rc;
} }
rc = cifs_setlk(file, fl, type, wait_flag, posix_lck, lock, unlock, rc = cifs_setlk(file, fl, type, wait_flag, posix_lck, lock, unlock,
......
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