[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <871qj0l8ln.fsf@email.froward.int.ebiederm.org>
Date: Sun, 28 May 2023 11:32:52 -0500
From: "Eric W. Biederman" <ebiederm@...ssion.com>
To: Christophe JAILLET <christophe.jaillet@...adoo.fr>
Cc: Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>,
Kees Cook <keescook@...omium.org>,
linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
linux-fsdevel@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [PATCH 1/2] binfmt: Use struct_size()
Christophe JAILLET <christophe.jaillet@...adoo.fr> writes:
> Use struct_size() instead of hand-writing it. It is less verbose, more
> robust and more informative.
Acked-by: "Eric W. Biederman" <ebiederm@...ssion.com>
Obviously correct transform.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
> ---
> Compile tested on arm
> ---
> fs/binfmt_elf_fdpic.c | 4 +---
> 1 file changed, 1 insertion(+), 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;
Powered by blists - more mailing lists