net: protect the older network cards driver's tx and rx process

Add netdev_lock in xxx_input and txavail to adapt to drivers that do not
use upperhalf.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
zhanghongyu
2025-08-22 12:03:02 +08:00
committed by Xiang Xiao
parent 6b625dfdf2
commit c8713a1b48
5 changed files with 27 additions and 4 deletions
+4
View File
@@ -33,6 +33,7 @@
#include <nuttx/net/netdev.h>
#include <nuttx/net/can.h>
#include <nuttx/net/netstats.h>
#include <nuttx/net/net.h>
#include "devif/devif.h"
#include "utils/utils.h"
@@ -289,6 +290,7 @@ int can_input(FAR struct net_driver_s *dev)
#ifdef CONFIG_NET_STATISTICS
g_netstats.can.recv++;
#endif
netdev_lock(dev);
if (dev->d_iob != NULL)
{
@@ -301,6 +303,7 @@ int can_input(FAR struct net_driver_s *dev)
dev->d_buf = buf;
netdev_unlock(dev);
return ret;
}
@@ -312,6 +315,7 @@ int can_input(FAR struct net_driver_s *dev)
#endif
}
netdev_unlock(dev);
return ret;
}