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

Unified · Split

kernel/groups.c+1−6
@@ -15,12 +15,7 @@ · 14 unmodified lines
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

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