You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2020/07/05 17:39:09 UTC

[incubator-nuttx] 02/02: drivers/can: enter_critical_section in can_poll

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

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

commit 908ee31e7d6a59ba616db039bb591428c4139c81
Author: Oleg Evseev <ev...@gmail.com>
AuthorDate: Sun Jul 5 19:10:54 2020 +0300

    drivers/can: enter_critical_section in can_poll
---
 drivers/can/can.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/can/can.c b/drivers/can/can.c
index 78842ec..2fa30da 100644
--- a/drivers/can/can.c
+++ b/drivers/can/can.c
@@ -1024,6 +1024,7 @@ static int can_poll(FAR struct file *filep, FAR struct pollfd *fds,
   FAR struct can_reader_s *reader = NULL;
   pollevent_t eventset;
   int ndx;
+  irqstate_t flags;
   int ret;
   int i;
 
@@ -1036,6 +1037,8 @@ static int can_poll(FAR struct file *filep, FAR struct pollfd *fds,
     }
 #endif
 
+  flags = enter_critical_section();
+
   DEBUGASSERT(filep->f_priv != NULL);
   reader = (FAR struct can_reader_s *)filep->f_priv;
 
@@ -1048,7 +1051,7 @@ static int can_poll(FAR struct file *filep, FAR struct pollfd *fds,
        * will abort the operation
        */
 
-      return ret;
+      goto return_with_irqdisabled;
     }
 
   /* Are we setting up the poll?  Or tearing it down? */
@@ -1162,6 +1165,9 @@ static int can_poll(FAR struct file *filep, FAR struct pollfd *fds,
 
 errout:
   can_givesem(&dev->cd_pollsem);
+
+return_with_irqdisabled:
+  leave_critical_section(flags);
   return ret;
 }