mirror of
https://github.com/apache/nuttx.git
synced 2026-05-21 04:52:02 +08:00
fs/procfs: fix potential null pointer access in procfs_opendir
Some entries have the opendir function set to NULL, for example
g_mount_operations.
A null pointer dereference can be triggered by an
opendir("/proc/fs/blocks") for example.
Signed-off-by: Beat Küng <beat-kueng@gmx.net>
This commit is contained in:
@@ -714,8 +714,12 @@ static int procfs_opendir(FAR struct inode *mountpt, FAR const char *relpath,
|
||||
* derived from struct procfs_dir_priv_s as dir.
|
||||
*/
|
||||
|
||||
DEBUGASSERT(g_procfs_entries[x].ops != NULL &&
|
||||
g_procfs_entries[x].ops->opendir != NULL);
|
||||
DEBUGASSERT(g_procfs_entries[x].ops != NULL);
|
||||
|
||||
if (g_procfs_entries[x].ops->opendir == NULL)
|
||||
{
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
ret = g_procfs_entries[x].ops->opendir(relpath, dir);
|
||||
if (ret == OK)
|
||||
|
||||
Reference in New Issue
Block a user