mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] objtool: initialize all of struct elf
@ 2023-06-29 10:05 Michal Kubecek
  2023-06-29 14:18 ` Josh Poimboeuf
  2023-07-10  8:13 ` [tip: objtool/urgent] " tip-bot2 for Michal Kubecek
  0 siblings, 2 replies; 3+ messages in thread
From: Michal Kubecek @ 2023-06-29 10:05 UTC (permalink / raw)
  To: Josh Poimboeuf, Peter Zijlstra, linux-kernel

Function elf_open_read() only zero initializes the initial part of
allocated struct elf; num_relocs member was recently added outside the
zeroed part so that it was left uninitialized, resulting in build failures
on some systems.

The partial initialization is a relic of times when struct elf had large
hash tables embedded. This is no longer the case so remove the trap and
initialize the whole structure instead.

Fixes: eb0481bbc4ce ("objtool: Fix reloc_hash size")
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
---
 tools/objtool/elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index d420b5d2e2b6..081befa4674b 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -1005,7 +1005,7 @@ struct elf *elf_open_read(const char *name, int flags)
 		perror("malloc");
 		return NULL;
 	}
-	memset(elf, 0, offsetof(struct elf, sections));
+	memset(elf, 0, sizeof(*elf));
 
 	INIT_LIST_HEAD(&elf->sections);
 
-- 
2.41.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-07-10  8:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-29 10:05 [PATCH] objtool: initialize all of struct elf Michal Kubecek
2023-06-29 14:18 ` Josh Poimboeuf
2023-07-10  8:13 ` [tip: objtool/urgent] " tip-bot2 for Michal Kubecek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®