summaryrefslogtreecommitdiffstats
path: root/fs/binfmt_elf_fdpic.c
diff options
context:
space:
mode:
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>2023-05-28 18:20:24 +0200
committerKees Cook <keescook@chromium.org>2023-05-31 00:49:46 +0200
commite6302d5a285b41209ada308ced6f9562cf1c616f (patch)
tree91a7773c80fe52634754ed986eec1e5d4c828359 /fs/binfmt_elf_fdpic.c
parentcoredump, vmcore: Set p_align to 4 for PT_NOTE (diff)
downloadlinux-e6302d5a285b41209ada308ced6f9562cf1c616f.tar.xz
linux-e6302d5a285b41209ada308ced6f9562cf1c616f.zip
binfmt: Use struct_size()
Use struct_size() instead of hand-writing it. It is less verbose, more robust and more informative. Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Acked-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/53150beae5dc04dac513dba391a2e4ae8696a7f3.1685290790.git.christophe.jaillet@wanadoo.fr
Diffstat (limited to 'fs/binfmt_elf_fdpic.c')
-rw-r--r--fs/binfmt_elf_fdpic.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index d76ad3d4f676..237ce388d06d 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -748,7 +748,6 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params,
struct elf32_phdr *phdr;
unsigned long load_addr, stop;
unsigned nloads, tmp;
- size_t size;
int loop, ret;
/* allocate a load map table */
@@ -760,8 +759,7 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params,
if (nloads == 0)
return -ELIBBAD;
- size = sizeof(*loadmap) + nloads * sizeof(*seg);
- loadmap = kzalloc(size, GFP_KERNEL);
+ loadmap = kzalloc(struct_size(loadmap, segs, nloads), GFP_KERNEL);
if (!loadmap)
return -ENOMEM;