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

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

commit 4df19fd6c596323ca0bc5ffb5d18b30af2ecd251
Author: Bowen Wang <[email protected]>
AuthorDate: Mon Jul 22 16:24:31 2024 +0800

    rpmsgfs/rpmsgfs_client: init the priv->wait before register rpmsg callback
    
    Should init the priv->wait before rpmsg_register_callback() because
    rpmsgfs_ns_bound() may has been called before rpmsg_register_callback()
    returned.
    
    Signed-off-by: Bowen Wang <[email protected]>
---
 fs/rpmsgfs/rpmsgfs_client.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/rpmsgfs/rpmsgfs_client.c b/fs/rpmsgfs/rpmsgfs_client.c
index 024e7d74e5..99dcdf4b57 100644
--- a/fs/rpmsgfs/rpmsgfs_client.c
+++ b/fs/rpmsgfs/rpmsgfs_client.c
@@ -744,6 +744,7 @@ int rpmsgfs_client_bind(FAR void **handle, FAR const char 
*cpuname)
       return -ENOMEM;
     }
 
+  nxsem_init(&priv->wait, 0, 0);
   strlcpy(priv->cpuname, cpuname, sizeof(priv->cpuname));
   ret = rpmsg_register_callback(priv,
                                 rpmsgfs_device_created,
@@ -752,11 +753,11 @@ int rpmsgfs_client_bind(FAR void **handle, FAR const char 
*cpuname)
                                 NULL);
   if (ret < 0)
     {
+      nxsem_destroy(&priv->wait);
       fs_heap_free(priv);
       return ret;
     }
 
-  nxsem_init(&priv->wait, 0, 0);
   *handle = priv;
 
   return 0;

Reply via email to