Skip to content

Commit

Permalink
groups: simplify struct group_info allocation
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Gao Xiang <[email protected]>
Cc: Micah Morton <[email protected]>
Cc: Michael Kelley <[email protected]>
Cc: "Peter Zijlstra (Intel)" <[email protected]>
Cc: Thomas Cedeno <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
chivay authored and torvalds committed Feb 26, 2021
1 parent c1f2649 commit e1e0141
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions kernel/groups.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit e1e0141

Please sign in to comment.