Skip to content

Commit 91cb74f

Browse files
Ronnie Sahlbergsmfrench
authored andcommitted
cifs: Change SMB2_open to return an iov for the error parameter
Signed-off-by: Ronnie Sahlberg <[email protected]> Signed-off-by: Steve French <[email protected]> Reviewed-by: Pavel Shilovsky <[email protected]>
1 parent e19b2bc commit 91cb74f

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

fs/cifs/smb2ops.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,6 +1451,7 @@ smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,
14511451
__u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
14521452
struct cifs_open_parms oparms;
14531453
struct cifs_fid fid;
1454+
struct kvec err_iov = {NULL, 0};
14541455
struct smb2_err_rsp *err_buf = NULL;
14551456
struct smb2_symlink_err_rsp *symlink;
14561457
unsigned int sub_len;
@@ -1473,15 +1474,16 @@ smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,
14731474
oparms.fid = &fid;
14741475
oparms.reconnect = false;
14751476

1476-
rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, &err_buf);
1477+
rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, &err_iov);
14771478

14781479
if (!rc || !err_buf) {
14791480
kfree(utf16_path);
14801481
return -ENOENT;
14811482
}
14821483

1484+
err_buf = err_iov.iov_base;
14831485
if (le32_to_cpu(err_buf->ByteCount) < sizeof(struct smb2_symlink_err_rsp) ||
1484-
get_rfc1002_length(err_buf) + server->vals->header_preamble_size < SMB2_SYMLINK_STRUCT_SIZE) {
1486+
err_iov.iov_len + server->vals->header_preamble_size < SMB2_SYMLINK_STRUCT_SIZE) {
14851487
kfree(utf16_path);
14861488
return -ENOENT;
14871489
}
@@ -1494,13 +1496,13 @@ smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,
14941496
print_len = le16_to_cpu(symlink->PrintNameLength);
14951497
print_offset = le16_to_cpu(symlink->PrintNameOffset);
14961498

1497-
if (get_rfc1002_length(err_buf) + server->vals->header_preamble_size <
1499+
if (err_iov.iov_len + server->vals->header_preamble_size <
14981500
SMB2_SYMLINK_STRUCT_SIZE + sub_offset + sub_len) {
14991501
kfree(utf16_path);
15001502
return -ENOENT;
15011503
}
15021504

1503-
if (get_rfc1002_length(err_buf) + server->vals->header_preamble_size <
1505+
if (err_iov.iov_len + server->vals->header_preamble_size <
15041506
SMB2_SYMLINK_STRUCT_SIZE + print_offset + print_len) {
15051507
kfree(utf16_path);
15061508
return -ENOENT;

fs/cifs/smb2pdu.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,7 +1807,7 @@ alloc_path_with_tree_prefix(__le16 **out_path, int *out_size, int *out_len,
18071807
int
18081808
SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
18091809
__u8 *oplock, struct smb2_file_all_info *buf,
1810-
struct smb2_err_rsp **err_buf)
1810+
struct kvec *err_iov)
18111811
{
18121812
struct smb2_create_req *req;
18131813
struct smb2_create_rsp *rsp;
@@ -1947,9 +1947,11 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
19471947

19481948
if (rc != 0) {
19491949
cifs_stats_fail_inc(tcon, SMB2_CREATE_HE);
1950-
if (err_buf && rsp)
1951-
*err_buf = kmemdup(rsp, get_rfc1002_length(rsp) + 4,
1952-
GFP_KERNEL);
1950+
if (err_iov && rsp) {
1951+
*err_iov = rsp_iov;
1952+
resp_buftype = CIFS_NO_BUFFER;
1953+
rsp = NULL;
1954+
}
19531955
goto creat_exit;
19541956
}
19551957

fs/cifs/smb2proto.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ extern int SMB2_tdis(const unsigned int xid, struct cifs_tcon *tcon);
122122
extern int SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms,
123123
__le16 *path, __u8 *oplock,
124124
struct smb2_file_all_info *buf,
125-
struct smb2_err_rsp **err_buf);
125+
struct kvec *err_iov);
126126
extern int SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon,
127127
u64 persistent_fid, u64 volatile_fid, u32 opcode,
128128
bool is_fsctl, char *in_data, u32 indatalen,

0 commit comments

Comments
 (0)