This is an automated email from the ASF dual-hosted git repository. jiuzhudong pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit e44690e22a48dd4f95e8c51b3974b71948af4ee0 Author: fangpeina <[email protected]> AuthorDate: Mon Jun 16 22:13:55 2025 +0800 drivers/leds: remove bo_closing as lu_lock can prevent race condition occurs remove enter_critical_section Signed-off-by: fangpeina <[email protected]> --- drivers/leds/userled_upper.c | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/drivers/leds/userled_upper.c b/drivers/leds/userled_upper.c index 884502dc9fb..1dcbda5d168 100644 --- a/drivers/leds/userled_upper.c +++ b/drivers/leds/userled_upper.c @@ -76,10 +76,6 @@ struct userled_open_s /* Supports a singly linked list */ FAR struct userled_open_s *bo_flink; - - /* The following will be true if we are closing */ - - volatile bool bo_closing; }; /**************************************************************************** @@ -174,8 +170,6 @@ static int userled_close(FAR struct file *filep) FAR struct userled_open_s *opriv; FAR struct userled_open_s *curr; FAR struct userled_open_s *prev; - irqstate_t flags; - bool closing; int ret; DEBUGASSERT(filep->f_priv); @@ -184,28 +178,6 @@ static int userled_close(FAR struct file *filep) DEBUGASSERT(inode->i_private); priv = inode->i_private; - /* Handle an improbable race conditions with the following atomic test - * and set. - * - * This is actually a pretty feeble attempt to handle this. The - * improbable race condition occurs if two different threads try to - * close the LED driver at the same time. The rule: don't do - * that! It is feeble because we do not really enforce stale pointer - * detection anyway. - */ - - flags = enter_critical_section(); - closing = opriv->bo_closing; - opriv->bo_closing = true; - leave_critical_section(flags); - - if (closing) - { - /* Another thread is doing the close */ - - return OK; - } - /* Get exclusive access to the driver structure */ ret = nxmutex_lock(&priv->lu_lock);
