Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Xiu Jianfeng and committed by
Chuck Lever
85a0d0c9 01d53a88

+4 -5
+4 -5
fs/nfsd/nfs4state.c
··· 1833 1833 int numslots = fattrs->maxreqs; 1834 1834 int slotsize = slot_bytes(fattrs); 1835 1835 struct nfsd4_session *new; 1836 - int mem, i; 1836 + int i; 1837 1837 1838 - BUILD_BUG_ON(NFSD_MAX_SLOTS_PER_SESSION * sizeof(struct nfsd4_slot *) 1839 - + sizeof(struct nfsd4_session) > PAGE_SIZE); 1840 - mem = numslots * sizeof(struct nfsd4_slot *); 1838 + BUILD_BUG_ON(struct_size(new, se_slots, NFSD_MAX_SLOTS_PER_SESSION) 1839 + > PAGE_SIZE); 1841 1840 1842 - new = kzalloc(sizeof(*new) + mem, GFP_KERNEL); 1841 + new = kzalloc(struct_size(new, se_slots, numslots), GFP_KERNEL); 1843 1842 if (!new) 1844 1843 return NULL; 1845 1844 /* allocate each struct nfsd4_slot and data cache in one piece */