diff --git a/fs/aio/aio_read.c b/fs/aio/aio_read.c index 27c9cfb0a03..468934bf804 100644 --- a/fs/aio/aio_read.c +++ b/fs/aio/aio_read.c @@ -219,6 +219,34 @@ int aio_read(FAR struct aiocb *aiocbp) DEBUGASSERT(aiocbp); + if (aiocbp->aio_reqprio < 0) + { + set_errno(EINVAL); + return ERROR; + } + + if (aiocbp->aio_fildes < 0) + { + /* the EBADF should be collected by aio_error(), we need return OK at + * here + */ + + aiocbp->aio_result = -EBADF; + return OK; + } + + /* for aio_read, the aio_offset should be large or equal than 0 */ + + if (aiocbp->aio_offset < 0) + { + /* the EINVAL should be collected by aio_error(), we need to return OK + * here + */ + + aiocbp->aio_result = -EINVAL; + return OK; + } + /* The result -EINPROGRESS means that the transfer has not yet completed */ sigwork_init(&aiocbp->aio_sigwork);