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

commit 4f7e03db2ef7bdcfbc56dc4def8ab41067472f15
Author: zhanghongyu <[email protected]>
AuthorDate: Tue Apr 22 15:28:41 2025 +0800

    netdev_upperhalf.c: add net_lock when vlan_foreach
    
    avoid illegal address access caused by removing vlan
    network cards during the traversal of vlan network cards
    
    Signed-off-by: zhanghongyu <[email protected]>
---
 drivers/net/netdev_upperhalf.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/netdev_upperhalf.c b/drivers/net/netdev_upperhalf.c
index 3c9e0438f8e..185e160d98e 100644
--- a/drivers/net/netdev_upperhalf.c
+++ b/drivers/net/netdev_upperhalf.c
@@ -483,6 +483,7 @@ netdev_upper_vlan_foreach(FAR struct netdev_upperhalf_s 
*upper,
 {
   int i;
 
+  net_lock();
   for (i = 0; i < CONFIG_NET_VLAN_COUNT; i++)
     {
       if (upper->vlan[i].dev)
@@ -490,6 +491,8 @@ netdev_upper_vlan_foreach(FAR struct netdev_upperhalf_s 
*upper,
           cb(upper->vlan[i].dev);
         }
     }
+
+  net_unlock();
 }
 #endif
 

Reply via email to