You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/11/11 14:47:08 UTC

[incubator-nuttx] branch master updated: Fix IOB functions The operations of struct iob_queue_s in qh_head & qh_tail are performed with interrupts disabled.

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/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 8d799f2  Fix IOB functions The operations of struct iob_queue_s in qh_head & qh_tail are performed with interrupts disabled.
8d799f2 is described below

commit 8d799f214879f8d14afd080f6cc58b2d46d8b56e
Author: Chery Dan <dd...@sina.com>
AuthorDate: Wed Nov 10 21:23:30 2021 +0800

    Fix IOB functions
    The operations of struct iob_queue_s in qh_head & qh_tail are performed with interrupts disabled.
    
    change iflags to flags
    
    add header file ref
    update for check
---
 mm/iob/iob_add_queue.c         | 6 ++++++
 mm/iob/iob_free_queue_qentry.c | 6 ++++++
 mm/iob/iob_remove_queue.c      | 4 ++++
 3 files changed, 16 insertions(+)

diff --git a/mm/iob/iob_add_queue.c b/mm/iob/iob_add_queue.c
index 31ff1fc..da8ca00 100644
--- a/mm/iob/iob_add_queue.c
+++ b/mm/iob/iob_add_queue.c
@@ -28,6 +28,8 @@
 #include <errno.h>
 #include <debug.h>
 
+#include <nuttx/irq.h>
+#include <nuttx/arch.h>
 #include <nuttx/mm/iob.h>
 
 #include "iob.h"
@@ -66,6 +68,8 @@ static int iob_add_queue_internal(FAR struct iob_s *iob,
   /* Add the container to the end of the queue */
 
   qentry->qe_flink = NULL;
+
+  irqstate_t flags = enter_critical_section();
   if (!iobq->qh_head)
     {
       iobq->qh_head = qentry;
@@ -78,6 +82,8 @@ static int iob_add_queue_internal(FAR struct iob_s *iob,
       iobq->qh_tail = qentry;
     }
 
+  leave_critical_section(flags);
+
   return 0;
 }
 
diff --git a/mm/iob/iob_free_queue_qentry.c b/mm/iob/iob_free_queue_qentry.c
index ef39084..07f0ebb 100644
--- a/mm/iob/iob_free_queue_qentry.c
+++ b/mm/iob/iob_free_queue_qentry.c
@@ -24,6 +24,9 @@
 
 #include <nuttx/config.h>
 #include <assert.h>
+
+#include <nuttx/irq.h>
+#include <nuttx/arch.h>
 #include <nuttx/mm/iob.h>
 
 #include "iob.h"
@@ -57,6 +60,7 @@ void iob_free_queue_qentry(FAR struct iob_s *iob,
   FAR struct iob_qentry_s *prev = NULL;
   FAR struct iob_qentry_s *qentry;
 
+  irqstate_t flags = enter_critical_section();
   for (qentry = iobq->qh_head; qentry != NULL;
        prev = qentry, qentry = qentry->qe_flink)
     {
@@ -89,6 +93,8 @@ void iob_free_queue_qentry(FAR struct iob_s *iob,
           break;
         }
     }
+
+  leave_critical_section(flags);
 }
 
 #endif /* CONFIG_IOB_NCHAINS > 0 */
diff --git a/mm/iob/iob_remove_queue.c b/mm/iob/iob_remove_queue.c
index 198b96f..7931d36 100644
--- a/mm/iob/iob_remove_queue.c
+++ b/mm/iob/iob_remove_queue.c
@@ -26,6 +26,8 @@
 
 #include <debug.h>
 
+#include <nuttx/irq.h>
+#include <nuttx/arch.h>
 #include <nuttx/mm/iob.h>
 
 #include "iob.h"
@@ -62,6 +64,7 @@ FAR struct iob_s *iob_remove_queue(FAR struct iob_queue_s *iobq)
 
   /* Remove the I/O buffer chain from the head of the queue */
 
+  irqstate_t flags = enter_critical_section();
   qentry = iobq->qh_head;
   if (qentry)
     {
@@ -79,6 +82,7 @@ FAR struct iob_s *iob_remove_queue(FAR struct iob_queue_s *iobq)
       iob_free_qentry(qentry);
     }
 
+  leave_critical_section(flags);
   return iob;
 }