summaryrefslogtreecommitdiffstats
path: root/fs/nfsd
diff options
context:
space:
mode:
authorXiu Jianfeng <xiujianfeng@huawei.com>2022-11-11 10:18:35 +0100
committerChuck Lever <cel@kernel.org>2022-12-10 17:01:11 +0100
commit85a0d0c9a58002ef7d1bf5e3ea630f4fbd42a4f0 (patch)
treeeb5861f0b65c6ac68b77b9d9266b97805d86ffb6 /fs/nfsd
parentnfsd: return error if nfs4_setacl fails (diff)
downloadlinux-85a0d0c9a58002ef7d1bf5e3ea630f4fbd42a4f0.tar.xz
linux-85a0d0c9a58002ef7d1bf5e3ea630f4fbd42a4f0.zip
NFSD: Use struct_size() helper in alloc_session()
Use struct_size() helper to simplify the code, no functional changes. Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Diffstat (limited to 'fs/nfsd')
-rw-r--r--fs/nfsd/nfs4state.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 2ec981fd2985..97badca3135e 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -1833,13 +1833,12 @@ static struct nfsd4_session *alloc_session(struct nfsd4_channel_attrs *fattrs,
int numslots = fattrs->maxreqs;
int slotsize = slot_bytes(fattrs);
struct nfsd4_session *new;
- int mem, i;
+ int i;
- BUILD_BUG_ON(NFSD_MAX_SLOTS_PER_SESSION * sizeof(struct nfsd4_slot *)
- + sizeof(struct nfsd4_session) > PAGE_SIZE);
- mem = numslots * sizeof(struct nfsd4_slot *);
+ BUILD_BUG_ON(struct_size(new, se_slots, NFSD_MAX_SLOTS_PER_SESSION)
+ > PAGE_SIZE);
- new = kzalloc(sizeof(*new) + mem, GFP_KERNEL);
+ new = kzalloc(struct_size(new, se_slots, numslots), GFP_KERNEL);
if (!new)
return NULL;
/* allocate each struct nfsd4_slot and data cache in one piece */