From c6815bba3b3437b7a7c0f0123abd50d715ceb44d Mon Sep 17 00:00:00 2001 From: dongjiuzhu1 Date: Fri, 5 Jul 2024 23:07:16 +0800 Subject: [PATCH] fs/mount: move inode_lock to before bind to avoid deadlock(nsh and rptun) Signed-off-by: dongjiuzhu1 --- fs/mount/fs_mount.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/mount/fs_mount.c b/fs/mount/fs_mount.c index b6804defe6..c541e85711 100644 --- a/fs/mount/fs_mount.c +++ b/fs/mount/fs_mount.c @@ -298,7 +298,7 @@ int nx_mount(FAR const char *source, FAR const char *target, #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS struct inode_search_s desc; #endif - void *fshandle = NULL; + FAR void *fshandle = NULL; int ret; /* Verify required pointer arguments */ @@ -442,6 +442,8 @@ int nx_mount(FAR const char *source, FAR const char *target, } #endif + inode_unlock(); + /* On failure, the bind method returns -errorcode */ #if defined(BDFS_SUPPORT) || defined(MDFS_SUPPORT) @@ -449,6 +451,7 @@ int nx_mount(FAR const char *source, FAR const char *target, #else ret = mops->bind(NULL, data, &fshandle); #endif + DEBUGVERIFY(inode_lock() >= 0); if (ret < 0) { /* The inode is unhappy with the driver for some reason. Back out