diff --git a/fs/vfs/fs_truncate.c b/fs/vfs/fs_truncate.c index 17b89edab65..4ecd06c13d4 100644 --- a/fs/vfs/fs_truncate.c +++ b/fs/vfs/fs_truncate.c @@ -155,7 +155,12 @@ int file_truncate(FAR struct file *filep, off_t length) int ftruncate(int fd, off_t length) { FAR struct file *filep; - int ret; + int ret = -EINVAL; + + if (length < 0) + { + goto errout; + } /* Get the file structure corresponding to the file descriptor. */