summaryrefslogtreecommitdiff
path: root/nuttx/fs
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/fs')
-rw-r--r--nuttx/fs/fs_lseek.c19
-rw-r--r--nuttx/fs/fs_write.c12
2 files changed, 20 insertions, 11 deletions
diff --git a/nuttx/fs/fs_lseek.c b/nuttx/fs/fs_lseek.c
index bcf66f51b..d2a2a8ca7 100644
--- a/nuttx/fs/fs_lseek.c
+++ b/nuttx/fs/fs_lseek.c
@@ -80,7 +80,7 @@ off_t file_seek(FAR struct file *filep, off_t offset, int whence)
int ret;
int err = OK;
- DEBUGASSERT(seekfile);
+ DEBUGASSERT(filep);
inode = filep->f_inode;
/* Invoke the file seek method if available */
@@ -173,9 +173,6 @@ errout:
off_t lseek(int fd, off_t offset, int whence)
{
FAR struct filelist *list;
- FAR struct file *filep;
- FAR struct inode *inode;
- int err;
/* Did we get a valid file descriptor? */
@@ -184,15 +181,17 @@ off_t lseek(int fd, off_t offset, int whence)
set_errno(EBADF);
return (off_t)ERROR;
}
+ else
+ {
+ /* Get the thread-specific file list */
- /* Get the thread-specific file list */
-
- list = sched_getfiles();
- DEBUGASSERT(list);
+ list = sched_getfiles();
+ DEBUGASSERT(list);
- /* Then let file_seek do the real work */
+ /* Then let file_seek do the real work */
- return file_seek(&list->fl_files[fd], offset, whence);
+ return file_seek(&list->fl_files[fd], offset, whence);
+ }
}
#endif
diff --git a/nuttx/fs/fs_write.c b/nuttx/fs/fs_write.c
index 7b6a8172f..3aad823a8 100644
--- a/nuttx/fs/fs_write.c
+++ b/nuttx/fs/fs_write.c
@@ -67,7 +67,17 @@ static inline ssize_t file_write(int fd, FAR const void *buf, size_t nbytes)
/* Get the thread-specific file list */
list = sched_getfiles();
- DEBUGASSERT(list);
+
+ /* The file list can be NULL under one obscure cornercase: When memory
+ * management debug output is enabled. Then there may be attempts to
+ * write to stdout from malloc before the group data has been allocated.
+ */
+
+ if (!list)
+ {
+ err = EAGAIN;
+ goto errout;
+ }
/* Was this file opened for write access? */