diff mbox series

[v3,4/8] sandbox: use O_CLOEXEC in os_open()

Message ID 20201027192928.16508-5-xypron.glpk@gmx.de
State Accepted
Commit c0b19f25a1a2ba935333899e5dcbe4429851cb18
Delegated to: Simon Glass
Headers show
Series sandbox: implement cold reset | expand

Commit Message

Heinrich Schuchardt Oct. 27, 2020, 7:29 p.m. UTC
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@gmx.de>
---
v3:
	no change
v2:
	new patch
---
 arch/sandbox/cpu/os.c | 5 +++++
 1 file changed, 5 insertions(+)

--
2.28.0

Comments

Simon Glass Nov. 3, 2020, 12:05 a.m. UTC | #1
On Tue, 27 Oct 2020 at 13:29, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> 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@gmx.de>
> ---
> v3:
>         no change
> v2:
>         new patch
> ---
>  arch/sandbox/cpu/os.c | 5 +++++
>  1 file changed, 5 insertions(+)
>

Reviewed-by: Simon Glass <sjg@chromium.org>
Simon Glass Nov. 3, 2020, 11:03 p.m. UTC | #2
On Tue, 27 Oct 2020 at 13:29, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> 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@gmx.de>
> ---
> v3:
>         no change
> v2:
>         new patch
> ---
>  arch/sandbox/cpu/os.c | 5 +++++
>  1 file changed, 5 insertions(+)
>

Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-dm, thanks!
diff mbox series

Patch

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);
 }