From b3894f16001c3ff4fb175c74cbe9e690f4c4e974 Mon Sep 17 00:00:00 2001 From: kamkow1 Date: Thu, 18 Sep 2025 00:54:53 +0200 Subject: [PATCH] Return an error code when a pipe is already present in a slot --- kernel/syscall/ipcpipe.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/syscall/ipcpipe.c b/kernel/syscall/ipcpipe.c index b8dc6de..7617528 100644 --- a/kernel/syscall/ipcpipe.c +++ b/kernel/syscall/ipcpipe.c @@ -49,6 +49,13 @@ int32_t SYSCALL5(sys_ipcpipe, pid1, pipenum1, cmd1, buffer1, len1) { } spinlock_acquire(&proc->pipes_spinlock); + if (proc->pipes[pipenum] != NULL) { + spinlock_release(&proc->pipes_spinlock); + ipc_pipefree(pipe); + dlfree(pipe); + ret = E_RESOURCEAVAIL; + goto done; + } proc->pipes[pipenum] = pipe; spinlock_release(&proc->pipes_spinlock);