cifs: Fix xid leak in cifs_flock()

[ Upstream commit 575e079c78 ]

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

Fixes: d0677992d2 ("cifs: add support for flock")
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Zhang Xiaoxu 2022-10-17 22:45:23 +08:00 committed by Greg Kroah-Hartman
parent dc283313d1
commit f8c9b4a963

View file

@ -1882,11 +1882,13 @@ int cifs_flock(struct file *file, int cmd, struct file_lock *fl)
struct cifsFileInfo *cfile;
__u32 type;
rc = -EACCES;
xid = get_xid();
if (!(fl->fl_flags & FL_FLOCK))
return -ENOLCK;
if (!(fl->fl_flags & FL_FLOCK)) {
rc = -ENOLCK;
free_xid(xid);
return rc;
}
cfile = (struct cifsFileInfo *)file->private_data;
tcon = tlink_tcon(cfile->tlink);
@ -1905,8 +1907,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
* know what it is
*/
rc = -EOPNOTSUPP;
free_xid(xid);
return -EOPNOTSUPP;
return rc;
}
rc = cifs_setlk(file, fl, type, wait_flag, posix_lck, lock, unlock,