From 29c6f112395cf45cdb5ca4b43d3f16fb8936ae5d Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Tue, 15 Dec 2020 15:46:40 +0800 Subject: [PATCH] fs: Skip call fs_checkfd if fd < 3 in fs_fdopen since the stdin, stdout and stderr may initialize later in userspace if CONFIG_DEV_CONSOLE isn't enabled. Note: it isn't bigger issue here to skip the check because vfs will check the validation again in read and write syscall Signed-off-by: Xiang Xiao --- fs/vfs/fs_fdopen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/vfs/fs_fdopen.c b/fs/vfs/fs_fdopen.c index cace0ca49d..44983794ec 100644 --- a/fs/vfs/fs_fdopen.c +++ b/fs/vfs/fs_fdopen.c @@ -115,7 +115,7 @@ int fs_fdopen(int fd, int oflags, FAR struct tcb_s *tcb, { FAR struct streamlist *slist; FAR FILE *stream; - int ret; + int ret = OK; /* Check input parameters */ @@ -164,7 +164,7 @@ int fs_fdopen(int fd, int oflags, FAR struct tcb_s *tcb, * more checks. */ - else + else if (fd >= 3) { ret = fs_checkfd(tcb, fd, oflags); }