diff mbox series

[60/66] bsd-user: Don't leak fd's when we can't writeback in do_bsd_pipe2

Message ID 20260515-misc-2026q2-v1-60-5438ca41b27a@bsdimp.com
State New
Headers show
Series bsd-user: Upstream most of the remaining system calls | expand

Commit Message

Warner Losh May 15, 2026, 9:19 p.m. UTC
When we can't write both the FDs back to the guest's memory, close them
so we don't leak them.

Signed-off-by: Warner Losh <imp@bsdimp.com>
---
 bsd-user/freebsd/os-file.h | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/bsd-user/freebsd/os-file.h b/bsd-user/freebsd/os-file.h
index bc31064a50..aa8d8bda74 100644
--- a/bsd-user/freebsd/os-file.h
+++ b/bsd-user/freebsd/os-file.h
@@ -34,6 +34,8 @@  static abi_long do_bsd_pipe2(CPUArchState *env, abi_ulong pipedes, int flags)
      */
     if (put_user_s32(host_pipe[0], pipedes) ||
         put_user_s32(host_pipe[1], pipedes + sizeof(host_pipe[0]))) {
+        close(host_pipe[0]);
+        close(host_pipe[1]);
         return -TARGET_EFAULT;
     }
     return 0;