mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
NFSD: Use struct_size() helper in alloc_session()
[ Upstream commit 85a0d0c9a5 ]
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
8b7be6ef58
commit
12e63680a7
@@ -1834,13 +1834,12 @@ static struct nfsd4_session *alloc_session(struct nfsd4_channel_attrs *fattrs,
|
|||||||
int numslots = fattrs->maxreqs;
|
int numslots = fattrs->maxreqs;
|
||||||
int slotsize = slot_bytes(fattrs);
|
int slotsize = slot_bytes(fattrs);
|
||||||
struct nfsd4_session *new;
|
struct nfsd4_session *new;
|
||||||
int mem, i;
|
int i;
|
||||||
|
|
||||||
BUILD_BUG_ON(NFSD_MAX_SLOTS_PER_SESSION * sizeof(struct nfsd4_slot *)
|
BUILD_BUG_ON(struct_size(new, se_slots, NFSD_MAX_SLOTS_PER_SESSION)
|
||||||
+ sizeof(struct nfsd4_session) > PAGE_SIZE);
|
> PAGE_SIZE);
|
||||||
mem = numslots * sizeof(struct nfsd4_slot *);
|
|
||||||
|
|
||||||
new = kzalloc(sizeof(*new) + mem, GFP_KERNEL);
|
new = kzalloc(struct_size(new, se_slots, numslots), GFP_KERNEL);
|
||||||
if (!new)
|
if (!new)
|
||||||
return NULL;
|
return NULL;
|
||||||
/* allocate each struct nfsd4_slot and data cache in one piece */
|
/* allocate each struct nfsd4_slot and data cache in one piece */
|
||||||
|
|||||||
Reference in New Issue
Block a user