Skip to content

Commit e1e0141

Browse files
chivaytorvalds
authored andcommitted
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 <hubert.jasudowicz@gmail.com> Cc: Gao Xiang <xiang@kernel.org> Cc: Micah Morton <mortonm@chromium.org> Cc: Michael Kelley <mikelley@microsoft.com> Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org> Cc: Thomas Cedeno <thomascedeno@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent c1f2649 commit e1e0141

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

‎kernel/groups.c‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@
1515
struct group_info *groups_alloc(int gidsetsize)
1616
{
1717
struct group_info *gi;
18-
unsigned int len;
19-
20-
len = sizeof(struct group_info) + sizeof(kgid_t) * gidsetsize;
21-
gi = kmalloc(len, GFP_KERNEL_ACCOUNT|__GFP_NOWARN|__GFP_NORETRY);
22-
if (!gi)
23-
gi = __vmalloc(len, GFP_KERNEL_ACCOUNT);
18+
gi = kvmalloc(struct_size(gi, gid, gidsetsize), GFP_KERNEL_ACCOUNT);
2419
if (!gi)
2520
return NULL;
2621

0 commit comments

Comments
 (0)