From: Heinrich Schuchardt <xypron.glpk@gmx.de>
Date: Wed, 12 May 2021 16:38:51 +0000 (+0200)
Subject: sandbox: fix sandbox_reset()
X-Git-Tag: v2025.01-rc5-pxa1908~1811^2~4
X-Git-Url: http://git.dujemihanovic.xyz/img/html/static/login.html?a=commitdiff_plain;h=825a9a94e1a5795e545156ead664a85403cda0e1;p=u-boot.git

sandbox: fix sandbox_reset()

state_uninit() and dm_uninit() are mutually exclusive:

state_uninit() prints via drivers. So it cannot be executed after
dm_uninit().

dm_uninit() requires memory. So it cannot be executed after state_uninit()
which releases all memory.

Just skip dm_uninit() when resetting the sandbox. We will wake up in a new
process and allocate new memory. So this cleanup is not required. We don't
do it in sandbox_exit() either.

This avoids a segmentation error when efi_reset_system_boottime() is
invoked by a UEFI application.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index ad17e17c59..777db4e952 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -436,9 +436,6 @@ void sandbox_reset(void)
 	if (state_uninit())
 		os_exit(2);
 
-	if (dm_uninit())
-		os_exit(2);
-
 	/* Restart U-Boot */
 	os_relaunch(os_argv);
 }