[PATCH] sandbox: disable tracing before unmapping RAM
Pavel Skripkin
paskripkin at gmail.com
Wed Apr 12 20:55:44 CEST 2023
Currently doing 'reset' command in sandbox with tracing enabled causes
SIGSEV
```
Hit any key to stop autoboot: 0
=>
=>
=> reset
resetting ...
Segmentation fault (core dumped)
```
Tracing callback uses RAM buffer for storing tracing reports, but
state_uninit() function unmaps whole RAM, which causes SIGSEV on umapped
memory inside tracing subsystem.
Fix it by disabling tracing before unmapping memory
Signed-off-by: Pavel Skripkin <paskripkin at gmail.com>
---
arch/sandbox/cpu/state.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c
index 69da378ab5..d8d5da25b1 100644
--- a/arch/sandbox/cpu/state.c
+++ b/arch/sandbox/cpu/state.c
@@ -10,6 +10,7 @@
#include <fdtdec.h>
#include <log.h>
#include <os.h>
+#include <trace.h>
#include <asm/malloc.h>
#include <asm/state.h>
#include <asm/test.h>
@@ -525,6 +526,9 @@ int state_uninit(void)
if (state->jumped_fname)
os_unlink(state->jumped_fname);
+ /* Disable tracing before unmapping RAM */
+ trace_set_enabled(0);
+
os_free(state->state_fdt);
os_free(state->ram_buf);
memset(state, '\0', sizeof(*state));
--
2.39.2
More information about the U-Boot
mailing list