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 <zhanghongyu@xiaomi.com>
This commit is contained in:
zhanghongyu
2025-04-22 15:28:41 +08:00
committed by Alan C. Assis
parent 00dfb5d1f3
commit 4f7e03db2e
+3
View File
@@ -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