From 314b80e0e9f8fee490b1d59a0c3db543513eb8be Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Fri, 26 Apr 2024 14:35:55 -0400 Subject: kernel: filedesc: Acquire mutex in write() Signed-off-by: Ian Moffett --- sys/kern/kern_filedesc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/kern/kern_filedesc.c b/sys/kern/kern_filedesc.c index 7e65d77..f7ca2c8 100644 --- a/sys/kern/kern_filedesc.c +++ b/sys/kern/kern_filedesc.c @@ -246,6 +246,7 @@ write(int fd, const void *buf, size_t count) return -EBADF; } + mutex_acquire(&desc->lock); if (desc->oflag != O_WRONLY && desc->oflag != O_WRONLY) { ret = -EACCES; goto cleanup; @@ -271,6 +272,7 @@ write(int fd, const void *buf, size_t count) goto cleanup; } cleanup: + mutex_release(&desc->lock); dynfree(in_buf); return ret; } -- cgit v1.2.3