This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 3d3db4a375 arm/imx9: sched_unlock should called after spin_unlock()
3d3db4a375 is described below

commit 3d3db4a3757eb0c7bdbc547f8694744a7fb2a3c1
Author: chao an <[email protected]>
AuthorDate: Tue Jan 14 00:36:58 2025 +0800

    arm/imx9: sched_unlock should called after spin_unlock()
    
    fix deadlock if sched_unlock switch out to other task
    
    Signed-off-by: chao an <[email protected]>
---
 arch/arm/src/imx9/imx9_flexcan.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/arm/src/imx9/imx9_flexcan.c b/arch/arm/src/imx9/imx9_flexcan.c
index 36b51ef0c8..1925d4e15e 100644
--- a/arch/arm/src/imx9/imx9_flexcan.c
+++ b/arch/arm/src/imx9/imx9_flexcan.c
@@ -807,6 +807,7 @@ static int imx9_txpoll(struct net_driver_s *dev)
   struct imx9_driver_s *priv =
     (struct imx9_driver_s *)dev->d_private;
   irqstate_t flags;
+  int ret = 0;
 
   /* If the polling resulted in data that should be sent out on the network,
    * the field d_len is set to a value > 0.
@@ -829,20 +830,18 @@ static int imx9_txpoll(struct net_driver_s *dev)
 
       if (imx9_txringfull(priv))
         {
-          sched_unlock();
-          spin_unlock_irqrestore(&priv->lock, flags);
-          return -EBUSY;
+          ret = -EBUSY;
         }
     }
 
-  sched_unlock();
   spin_unlock_irqrestore(&priv->lock, flags);
+  sched_unlock();
 
   /* If zero is returned, the polling will continue until all connections
    * have been examined.
    */
 
-  return 0;
+  return ret;
 }
 
 /****************************************************************************

Reply via email to