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:
Beat Küng 2025-04-09 11:11:31 +02:00 committed by Alan C. Assis
parent 0de4bd7938
commit ac2078a8bf

View file

@ -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)