kexec: avoid calculating array size twice
Avoid calculating array size twice in kexec_purgatory_setup_sechdrs(). Once using array_size(), and once open-coded. Flagged by Coccinelle: .../kexec_file.c:881:8-25: WARNING: array_size is already used (line 877) to compute the same size No functional change intended. Compile tested only. Link: https://lkml.kernel.org/r/20230525-kexec-array_size-v1-1-8b4bf4f7500a@kernel.org Signed-off-by: Simon Horman <horms@kernel.org> Acked-by: Baoquan He <bhe@redhat.com> Cc: Eric W. Biederman <ebiederm@xmission.com> Cc: Zhen Lei <thunder.leizhen@huawei.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
048a988326
commit
4df3504e2f
|
@ -867,6 +867,7 @@ static int kexec_purgatory_setup_sechdrs(struct purgatory_info *pi,
|
||||||
{
|
{
|
||||||
unsigned long bss_addr;
|
unsigned long bss_addr;
|
||||||
unsigned long offset;
|
unsigned long offset;
|
||||||
|
size_t sechdrs_size;
|
||||||
Elf_Shdr *sechdrs;
|
Elf_Shdr *sechdrs;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -874,11 +875,11 @@ static int kexec_purgatory_setup_sechdrs(struct purgatory_info *pi,
|
||||||
* The section headers in kexec_purgatory are read-only. In order to
|
* The section headers in kexec_purgatory are read-only. In order to
|
||||||
* have them modifiable make a temporary copy.
|
* have them modifiable make a temporary copy.
|
||||||
*/
|
*/
|
||||||
sechdrs = vzalloc(array_size(sizeof(Elf_Shdr), pi->ehdr->e_shnum));
|
sechdrs_size = array_size(sizeof(Elf_Shdr), pi->ehdr->e_shnum);
|
||||||
|
sechdrs = vzalloc(sechdrs_size);
|
||||||
if (!sechdrs)
|
if (!sechdrs)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
memcpy(sechdrs, (void *)pi->ehdr + pi->ehdr->e_shoff,
|
memcpy(sechdrs, (void *)pi->ehdr + pi->ehdr->e_shoff, sechdrs_size);
|
||||||
pi->ehdr->e_shnum * sizeof(Elf_Shdr));
|
|
||||||
pi->sechdrs = sechdrs;
|
pi->sechdrs = sechdrs;
|
||||||
|
|
||||||
offset = 0;
|
offset = 0;
|
||||||
|
|
Loading…
Reference in New Issue