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

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

commit a8be1083608e424f4bc8112b1eeaf830fbede652
Author: daichuan <[email protected]>
AuthorDate: Mon Dec 8 16:34:11 2025 +0800

    net: modify g_netdevices_lock with rmutex_t
    
    With IP forwarding, netdev_foreach() and netdev_verify() both run under
    netdev_list_lock while a caller may already hold it, so the list lock can
    be taken recursively.  Change g_netdevices_lock from mutex_t to rmutex_t
    to allow the nested acquisition.
    
    Signed-off-by: daichuan <[email protected]>
---
 net/netdev/netdev_register.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/netdev/netdev_register.c b/net/netdev/netdev_register.c
index e92e0d992b1..a80b34ab384 100644
--- a/net/netdev/netdev_register.c
+++ b/net/netdev/netdev_register.c
@@ -110,7 +110,7 @@ uint32_t g_devfreed;
  * Private Data
  ****************************************************************************/
 
-static mutex_t g_netdevices_lock = NXMUTEX_INITIALIZER;
+static rmutex_t g_netdevices_lock = NXRMUTEX_INITIALIZER;
 
 /****************************************************************************
  * Private Functions
@@ -200,6 +200,7 @@ static int get_ifindex(void)
   for (ndx = 0; ndx < MAX_IFINDEX; ndx++)
     {
       uint32_t bit = 1UL << ndx;
+
       if ((devset & bit) == 0)
         {
           /* Indicate that this index is in use */
@@ -233,7 +234,7 @@ static int get_ifindex(void)
 
 void netdev_list_lock(void)
 {
-  nxmutex_lock(&g_netdevices_lock);
+  nxrmutex_lock(&g_netdevices_lock);
 }
 
 /****************************************************************************
@@ -246,7 +247,7 @@ void netdev_list_lock(void)
 
 void netdev_list_unlock(void)
 {
-  nxmutex_unlock(&g_netdevices_lock);
+  nxrmutex_unlock(&g_netdevices_lock);
 }
 
 /****************************************************************************

Reply via email to