History

groups: simplify struct group_info allocation

Combine kmalloc and vmalloc into a single call. Use struct_size macro instead of direct size calculation.

Hubert Jasudowicz committed 5 years ago

Commit e1e01411 parent c1f26491 file · +1 −6Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/groups.c+1−6
@@ -15,12 +15,7 @@ · 14 unmodified lines
15struct group_info *groups_alloc(int gidsetsize)15struct group_info *groups_alloc(int gidsetsize)
16{16{
17 struct group_info *gi;17 struct group_info *gi;
18 unsigned int len;18 gi = kvmalloc(struct_size(gi, gid, gidsetsize), GFP_KERNEL_ACCOUNT);
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);
24 if (!gi)19 if (!gi)
25 return NULL;20 return NULL;
26 21

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t