[PATCH v2 4/8] sandbox: use O_CLOEXEC in os_open()

Heinrich Schuchardt xypron.glpk at gmx.de
Tue Oct 27 19:47:00 CET 2020


During a cold reset execv() is used to relaunch the U-Boot binary.
We must ensure that all files are closed in this case.

Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
v2:
	new patch
---
 arch/sandbox/cpu/os.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index c461fb0db0..7e474d6364 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -80,6 +80,11 @@ int os_open(const char *pathname, int os_flags)
 		flags |= O_CREAT;
 	if (os_flags & OS_O_TRUNC)
 		flags |= O_TRUNC;
+	/*
+	 * During a cold reset execv() is used to relaunch the U-Boot binary.
+	 * We must ensure that all files are closed in this case.
+	 */
+	flags |= O_CLOEXEC;

 	return open(pathname, flags, 0777);
 }
--
2.28.0



More information about the U-Boot mailing list