diff options
author | Hubert Jasudowicz <hubert.jasudowicz@gmail.com> | 2021-02-26 02:21:07 +0100 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2021-02-26 18:41:03 +0100 |
commit | e1e014115dfd48ab3e3691ce46f9484ce12e67d4 (patch) | |
tree | 985f8c2183614c6e28849299ea3ec9c4d9616a87 /kernel | |
parent | groups: use flexible-array member in struct group_info (diff) | |
download | linux-e1e014115dfd48ab3e3691ce46f9484ce12e67d4.tar.xz linux-e1e014115dfd48ab3e3691ce46f9484ce12e67d4.zip |
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>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/groups.c | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/kernel/groups.c b/kernel/groups.c index fe7e6385530e..787b381c7c00 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; |