aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorThomas Weißschuh2024-02-13 18:13:28 +0100
committerTom Rini2024-03-02 12:26:56 -0500
commit39162d9348584ad6d86cb2a3a540ca38f8be7ff8 (patch)
treec59108f24be5abbe0cb1e5202a41793f38c1e174 /common
parent657bd30c6b3ee8c80a94ebfe7c8b5c4b027ae038 (diff)
log: fixup log_head after relocating global data
When `gd` is relocated during `spl_relocate_stack_gd()` the doubly-linked circular list in the `log_head` member is broken. The last element of the list should point back to the initial `list_head`, but as the initial `list_head` is moved the pointer becomes stale. As a result the loop in `log_dispatch` would never finish. Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/log.c5
-rw-r--r--common/spl/spl.c3
2 files changed, 8 insertions, 0 deletions
diff --git a/common/log.c b/common/log.c
index b2de57fcb3b..42d35f04b68 100644
--- a/common/log.c
+++ b/common/log.c
@@ -428,6 +428,11 @@ int log_device_set_enable(struct log_driver *drv, bool enable)
return 0;
}
+void log_fixup_for_gd_move(struct global_data *new_gd)
+{
+ new_gd->log_head.prev->next = &new_gd->log_head;
+}
+
int log_init(void)
{
struct log_driver *drv = ll_entry_start(struct log_driver, log_driver);
diff --git a/common/spl/spl.c b/common/spl/spl.c
index b65c439e7aa..e06bc75d36b 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -909,6 +909,9 @@ ulong spl_relocate_stack_gd(void)
#if CONFIG_IS_ENABLED(DM)
dm_fixup_for_gd_move(new_gd);
#endif
+#if CONFIG_IS_ENABLED(LOG)
+ log_fixup_for_gd_move(new_gd);
+#endif
#if !defined(CONFIG_ARM) && !defined(CONFIG_RISCV)
gd = new_gd;
#endif