Combine kmalloc and vmalloc into a single call. Use struct_size macro instead of direct size calculation.
Showing the changes to kernel (1 of 1 file). Show all
Unified · Split
| @@ -15,12 +15,7 @@ · 14 unmodified lines | ||
| 15 | 15 | struct group_info *groups_alloc(int gidsetsize) |
| 16 | 16 | { |
| 17 | 17 | 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); | |
| 24 | 19 | if (!gi) |
| 25 | 20 | return NULL; |
| 26 | 21 | |