This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 99ca0dbf9da bugfix:the inode may have been removed by other core in SMP
99ca0dbf9da is described below

commit 99ca0dbf9daa6d5ae32c7601133d7c39cccbef8a
Author: guohao15 <[email protected]>
AuthorDate: Wed Apr 9 11:34:16 2025 +0800

    bugfix:the inode may have been removed by other core in SMP
    
    The inode may has been unlinked from the tree in other core, but it is not 
yet freed.
    
    Signed-off-by: guohao15 <[email protected]>
---
 fs/mqueue/mq_unlink.c     | 10 ++++++----
 fs/semaphore/sem_unlink.c | 11 ++++++-----
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/fs/mqueue/mq_unlink.c b/fs/mqueue/mq_unlink.c
index a0a2a275b65..508231ee6f4 100644
--- a/fs/mqueue/mq_unlink.c
+++ b/fs/mqueue/mq_unlink.c
@@ -153,12 +153,14 @@ int file_mq_unlink(FAR const char *mq_name)
 
   ret = inode_remove(fullpath);
 
-  /* inode_remove() should always fail with -EBUSY because we hae a reference
-   * on the inode.  -EBUSY means that the inode was, indeed, unlinked but
-   * thatis could not be freed because there are references.
+  /* The inode may has been unlinked from the tree in other core,
+   * but it is not yet freed.
    */
 
-  DEBUGASSERT(ret >= 0 || ret == -EBUSY);
+  if (ret < 0 && ret != -EBUSY)
+    {
+      goto errout_with_lock;
+    }
 
   /* Now we do not release the reference count in the normal way (by calling
    * inode release.  Rather, we call mq_inode_release().  mq_inode_release
diff --git a/fs/semaphore/sem_unlink.c b/fs/semaphore/sem_unlink.c
index fc0186e7f13..9fde96acc95 100644
--- a/fs/semaphore/sem_unlink.c
+++ b/fs/semaphore/sem_unlink.c
@@ -118,13 +118,14 @@ int nxsem_unlink(FAR const char *name)
 
   ret = inode_remove(fullpath);
 
-  /* inode_remove() should always fail with -EBUSY because we hae a reference
-   * on the inode.  -EBUSY means that the inode was, indeed, unlinked but
-   * thatis could not be freed because there are references.
+  /* The inode may has been unlinked from the tree in other core,
+   * but it is not yet freed.
    */
 
-  DEBUGASSERT(ret >= 0 || ret == -EBUSY);
-  UNUSED(ret);
+  if (ret < 0 && ret != -EBUSY)
+    {
+      goto errout_with_lock;
+    }
 
   /* Now we do not release the reference count in the normal way (by calling
    * inode release.  Rather, we call sem_close().  sem_close will decrement

Reply via email to