From: Hubert Jasudowicz Date: Fri, 26 Feb 2021 01:21:07 +0000 (-0800) Subject: groups: simplify struct group_info allocation X-Git-Tag: accepted/tizen/unified/20230118.172025~7728^2~29 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e1e014115dfd48ab3e3691ce46f9484ce12e67d4;p=platform%2Fkernel%2Flinux-rpi.git groups: simplify struct group_info allocation Combine kmalloc and vmalloc into a single call. Use struct_size macro instead of direct size calculation. Link: https://lkml.kernel.org/r/ba9ba5beea9a44b7196c41a0d9528abd5f20dd2e.1611620846.git.hubert.jasudowicz@gmail.com Signed-off-by: Hubert Jasudowicz Cc: Gao Xiang Cc: Micah Morton Cc: Michael Kelley Cc: "Peter Zijlstra (Intel)" Cc: Thomas Cedeno Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/kernel/groups.c b/kernel/groups.c index fe7e638..787b381 100644 --- a/kernel/groups.c +++ b/kernel/groups.c @@ -15,12 +15,7 @@ struct group_info *groups_alloc(int gidsetsize) { struct group_info *gi; - unsigned int len; - - len = sizeof(struct group_info) + sizeof(kgid_t) * gidsetsize; - gi = kmalloc(len, GFP_KERNEL_ACCOUNT|__GFP_NOWARN|__GFP_NORETRY); - if (!gi) - gi = __vmalloc(len, GFP_KERNEL_ACCOUNT); + gi = kvmalloc(struct_size(gi, gid, gidsetsize), GFP_KERNEL_ACCOUNT); if (!gi) return NULL;