summaryrefslogtreecommitdiff
path: root/components/dfs
diff options
context:
space:
mode:
authorguo <[email protected]>2022-01-28 16:38:32 +0800
committerGitHub <[email protected]>2022-01-28 16:38:32 +0800
commit580194f5f0f18371c08bb926a8fed7d7093cea67 (patch)
tree17b0dac3ea40283f1b9268a56f3577c9d3e94d05 /components/dfs
parentcd929f04f680ea243810c988558c717c193740b8 (diff)
parent500d26c2570bb3d905e38aed05fd9c9b324a8f6e (diff)
Merge pull request #4740 from Guozhanxin/scheduler_check
Diffstat (limited to 'components/dfs')
-rw-r--r--components/dfs/filesystems/devfs/devfs.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/components/dfs/filesystems/devfs/devfs.c b/components/dfs/filesystems/devfs/devfs.c
index d60f7ddc9b..8e58fb9f53 100644
--- a/components/dfs/filesystems/devfs/devfs.c
+++ b/components/dfs/filesystems/devfs/devfs.c
@@ -144,11 +144,15 @@ int dfs_device_fs_open(struct dfs_fd *file)
{
count ++;
}
+ rt_exit_critical();
root_dirent = (struct device_dirent *)rt_malloc(sizeof(struct device_dirent) +
count * sizeof(rt_device_t));
if (root_dirent != RT_NULL)
{
+ /* lock scheduler */
+ rt_enter_critical();
+
root_dirent->devices = (rt_device_t *)(root_dirent + 1);
root_dirent->read_index = 0;
root_dirent->device_count = count;
@@ -156,12 +160,18 @@ int dfs_device_fs_open(struct dfs_fd *file)
/* get all device node */
for (node = information->object_list.next; node != &(information->object_list); node = node->next)
{
+ /* avoid memory write through */
+ if (count == root_dirent->device_count)
+ {
+ rt_kprintf("warning: There are newly added devices that are not displayed!");
+ break;
+ }
object = rt_list_entry(node, struct rt_object, list);
root_dirent->devices[count] = (rt_device_t)object;
count ++;
}
+ rt_exit_critical();
}
- rt_exit_critical();
/* set data */
file->data = root_dirent;