Commit 933148a4 authored by Paulo Alcantara's avatar Paulo Alcantara Committed by Steve French

smb: client: reduce stack usage in smb_send_rqst()

Clang warns about exceeded stack frame size

  fs/smb/client/transport.c:420:1: warning: stack frame size (1048)
  exceeds limit (1024) in 'smb_send_rqst' [-Wframe-larger-than]

Fix this by allocating a structure that will hold transform header and
compound requests.
Signed-off-by: default avatarPaulo Alcantara (SUSE) <pc@manguebit.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 946ad1b8
...@@ -416,13 +416,19 @@ __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst, ...@@ -416,13 +416,19 @@ __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
return rc; return rc;
} }
struct send_req_vars {
struct smb2_transform_hdr tr_hdr;
struct smb_rqst rqst[MAX_COMPOUND];
struct kvec iov;
};
static int static int
smb_send_rqst(struct TCP_Server_Info *server, int num_rqst, smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
struct smb_rqst *rqst, int flags) struct smb_rqst *rqst, int flags)
{ {
struct kvec iov; struct send_req_vars *vars;
struct smb2_transform_hdr *tr_hdr; struct smb_rqst *cur_rqst;
struct smb_rqst cur_rqst[MAX_COMPOUND]; struct kvec *iov;
int rc; int rc;
if (!(flags & CIFS_TRANSFORM_REQ)) if (!(flags & CIFS_TRANSFORM_REQ))
...@@ -436,16 +442,15 @@ smb_send_rqst(struct TCP_Server_Info *server, int num_rqst, ...@@ -436,16 +442,15 @@ smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
return -EIO; return -EIO;
} }
tr_hdr = kzalloc(sizeof(*tr_hdr), GFP_NOFS); vars = kzalloc(sizeof(*vars), GFP_NOFS);
if (!tr_hdr) if (!vars)
return -ENOMEM; return -ENOMEM;
cur_rqst = vars->rqst;
iov = &vars->iov;
memset(&cur_rqst[0], 0, sizeof(cur_rqst)); iov->iov_base = &vars->tr_hdr;
memset(&iov, 0, sizeof(iov)); iov->iov_len = sizeof(vars->tr_hdr);
cur_rqst[0].rq_iov = iov;
iov.iov_base = tr_hdr;
iov.iov_len = sizeof(*tr_hdr);
cur_rqst[0].rq_iov = &iov;
cur_rqst[0].rq_nvec = 1; cur_rqst[0].rq_nvec = 1;
rc = server->ops->init_transform_rq(server, num_rqst + 1, rc = server->ops->init_transform_rq(server, num_rqst + 1,
...@@ -456,7 +461,7 @@ smb_send_rqst(struct TCP_Server_Info *server, int num_rqst, ...@@ -456,7 +461,7 @@ smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
rc = __smb_send_rqst(server, num_rqst + 1, &cur_rqst[0]); rc = __smb_send_rqst(server, num_rqst + 1, &cur_rqst[0]);
smb3_free_compound_rqst(num_rqst, &cur_rqst[1]); smb3_free_compound_rqst(num_rqst, &cur_rqst[1]);
out: out:
kfree(tr_hdr); kfree(vars);
return rc; return rc;
} }
......
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