Skip to content

Commit 2575e63

Browse files
committed
Merge tag 'v6.17-rc3-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6
Pull smb client fixes from Steve French: - Fix possible refcount leak in compound operations - Fix remap_file_range() return code mapping, found by generic/157 * tag 'v6.17-rc3-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6: fs/smb: Fix inconsistent refcnt update smb3 client: fix return code mapping of remap_file_range
2 parents 4694472 + ab529e6 commit 2575e63

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

fs/smb/client/cifsfs.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,6 +1358,20 @@ static loff_t cifs_remap_file_range(struct file *src_file, loff_t off,
13581358
truncate_setsize(target_inode, new_size);
13591359
fscache_resize_cookie(cifs_inode_cookie(target_inode),
13601360
new_size);
1361+
} else if (rc == -EOPNOTSUPP) {
1362+
/*
1363+
* copy_file_range syscall man page indicates EINVAL
1364+
* is returned e.g when "fd_in and fd_out refer to the
1365+
* same file and the source and target ranges overlap."
1366+
* Test generic/157 was what showed these cases where
1367+
* we need to remap EOPNOTSUPP to EINVAL
1368+
*/
1369+
if (off >= src_inode->i_size) {
1370+
rc = -EINVAL;
1371+
} else if (src_inode == target_inode) {
1372+
if (off + len > destoff)
1373+
rc = -EINVAL;
1374+
}
13611375
}
13621376
if (rc == 0 && new_size > target_cifsi->netfs.zero_point)
13631377
target_cifsi->netfs.zero_point = new_size;

fs/smb/client/smb2inode.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,10 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
207207
server = cifs_pick_channel(ses);
208208

209209
vars = kzalloc(sizeof(*vars), GFP_ATOMIC);
210-
if (vars == NULL)
211-
return -ENOMEM;
210+
if (vars == NULL) {
211+
rc = -ENOMEM;
212+
goto out;
213+
}
212214
rqst = &vars->rqst[0];
213215
rsp_iov = &vars->rsp_iov[0];
214216

@@ -864,6 +866,7 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
864866
smb2_should_replay(tcon, &retries, &cur_sleep))
865867
goto replay_again;
866868

869+
out:
867870
if (cfile)
868871
cifsFileInfo_put(cfile);
869872

0 commit comments

Comments
 (0)