/fs/inode: Add checks for NULL pointers as recommended by Junmin Kim <trimind0210@gmail.com>.

This commit is contained in:
Gregory Nutt 2019-12-10 07:50:27 -06:00
parent abdafaeccc
commit 0ef5500e01
2 changed files with 6 additions and 2 deletions

View File

@ -1,7 +1,7 @@
/****************************************************************************
* fs/inode/fs_filedetach.c
*
* Copyright (C) 2016-2017 Gregory Nutt. All rights reserved.
* Copyright (C) 2016-2017, 2019 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -114,6 +114,8 @@ int file_detach(int fd, FAR struct file *filep)
FAR struct filelist *list;
FAR struct file *parent;
DEBUGASSERT(filep != NULL);
/* Verify the file descriptor range */
if (fd < 0 || fd >= CONFIG_NFILE_DESCRIPTORS)

View File

@ -1,7 +1,7 @@
/****************************************************************************
* fs/inode/fs_fileopen.c
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Copyright (C) 2018-2019 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -78,6 +78,8 @@ int file_open(FAR struct file *filep, FAR const char *path, int oflags, ...)
int ret;
int fd;
DEBUGASSERT(filep != NULL && path != NULL);
/* At present, this is just a placeholder. It is just a wrapper around
* nx_open() followed by a called to file_detach(). Ideally, this should
* a native open function that opens the VFS node directly without using