From c331bb9ac5e7b76abe290cbc41b118ad93ef9f75 Mon Sep 17 00:00:00 2001 From: Zhe Weng Date: Tue, 24 Dec 2024 20:14:20 +0800 Subject: [PATCH] netdev/upper: Fix wrong CPU when RSS is disabled When `CONFIG_NETDEV_RSS` is disabled, `NETDEV_THREAD_COUNT` will be 1, and we should not access `upper->sem[cpu]` with `cpu > 0`. Signed-off-by: Zhe Weng --- drivers/net/netdev_upperhalf.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/netdev_upperhalf.c b/drivers/net/netdev_upperhalf.c index 98d8f0bf88ca2..ec51c71b10708 100644 --- a/drivers/net/netdev_upperhalf.c +++ b/drivers/net/netdev_upperhalf.c @@ -754,7 +754,11 @@ static inline void netdev_upper_queue_work(FAR struct net_driver_s *dev) FAR struct netdev_upperhalf_s *upper = dev->d_private; #ifdef CONFIG_NETDEV_WORK_THREAD +# ifdef CONFIG_NETDEV_RSS int cpu = this_cpu(); +# else + const int cpu = 0; +# endif int semcount; if (nxsem_get_value(&upper->sem[cpu], &semcount) == OK &&