* [PATCH 1/2] groups: Use flexible-array member in struct group_info
@ 2021-01-26 1:37 Hubert Jasudowicz
2021-01-26 1:37 ` [PATCH 2/2] groups: Simplify struct group_info allocation Hubert Jasudowicz
0 siblings, 1 reply; 2+ messages in thread
From: Hubert Jasudowicz @ 2021-01-26 1:37 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
Replace zero-size array with flexible array member, as recommended by
the docs.
Signed-off-by: Hubert Jasudowicz <hubert.jasudowicz@gmail.com>
---
Hi, get_maintainers doesn't return anything except for the mailing list.
Sending to Andrew Morton as last resort. Sorry for accidental spam.
diff --git a/include/linux/cred.h b/include/linux/cred.h
index 18639c069263..4c6350503697 100644
--- a/include/linux/cred.h
+++ b/include/linux/cred.h
@@ -25,7 +25,7 @@ struct inode;
struct group_info {
atomic_t usage;
int ngroups;
- kgid_t gid[0];
+ kgid_t gid[];
} __randomize_layout;
/**
base-commit: 6ee1d745b7c9fd573fba142a2efdad76a9f1cb04
--
2.30.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 2/2] groups: Simplify struct group_info allocation
2021-01-26 1:37 [PATCH 1/2] groups: Use flexible-array member in struct group_info Hubert Jasudowicz
@ 2021-01-26 1:37 ` Hubert Jasudowicz
0 siblings, 0 replies; 2+ messages in thread
From: Hubert Jasudowicz @ 2021-01-26 1:37 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-kernel, Peter Zijlstra (Intel),
Micah Morton, Gao Xiang, Michael Kelley, Thomas Cedeno
Combine kmalloc and vmalloc into a single call.
Use struct_size macro instead of direct size calculation.
Signed-off-by: Hubert Jasudowicz <hubert.jasudowicz@gmail.com>
---
kernel/groups.c | 7 +------
1 file changed, 1 insertion(+), 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;
--
2.30.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-26 10:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-26 1:37 [PATCH 1/2] groups: Use flexible-array member in struct group_info Hubert Jasudowicz
2021-01-26 1:37 ` [PATCH 2/2] groups: Simplify struct group_info allocation Hubert Jasudowicz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).