diff --git a/fs/vfs/fs_open.c b/fs/vfs/fs_open.c index f0347828656..c3e56e6a736 100644 --- a/fs/vfs/fs_open.c +++ b/fs/vfs/fs_open.c @@ -99,15 +99,21 @@ int open(const char *path, int oflags, ...) int ret; int fd; + /* open() is a cancellation point */ + + (void)enter_cancellation_point(); + + if (path == NULL) + { + set_errno(EINVAL); + goto errout; + } + #ifdef CONFIG_FILE_MODE # ifdef CONFIG_CPP_HAVE_WARNING # warning "File creation not implemented" # endif - /* open() is a cancellation point */ - - (void)enter_cancellation_point(); - /* If the file is opened for creation, then get the mode bits */ if ((oflags & (O_WRONLY | O_CREAT)) != 0) diff --git a/fs/vfs/fs_write.c b/fs/vfs/fs_write.c index 9fa5f1c0aca..0a40a1ff27b 100644 --- a/fs/vfs/fs_write.c +++ b/fs/vfs/fs_write.c @@ -153,6 +153,13 @@ ssize_t write(int fd, FAR const void *buf, size_t nbytes) (void)enter_cancellation_point(); + if (buf == NULL) + { + set_errno(EINVAL); + ret = ERROR; + goto errout; + } + /* Did we get a valid file descriptor? */ #if CONFIG_NFILE_DESCRIPTORS > 0 @@ -167,7 +174,7 @@ ssize_t write(int fd, FAR const void *buf, size_t nbytes) ret = send(fd, buf, nbytes, 0); #else set_errno(EBADF); - ret = ERROR ERROR; + ret = ERROR; #endif } @@ -202,6 +209,7 @@ ssize_t write(int fd, FAR const void *buf, size_t nbytes) } #endif +errout: leave_cancellation_point(); return ret; }