From 8d799f214879f8d14afd080f6cc58b2d46d8b56e Mon Sep 17 00:00:00 2001 From: Chery Dan Date: Wed, 10 Nov 2021 21:23:30 +0800 Subject: [PATCH] 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 31ff1fc620..da8ca00936 100644 --- a/mm/iob/iob_add_queue.c +++ b/mm/iob/iob_add_queue.c @@ -28,6 +28,8 @@ #include #include +#include +#include #include #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 ef390845cb..07f0ebbe53 100644 --- a/mm/iob/iob_free_queue_qentry.c +++ b/mm/iob/iob_free_queue_qentry.c @@ -24,6 +24,9 @@ #include #include + +#include +#include #include #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 198b96f3e7..7931d362f0 100644 --- a/mm/iob/iob_remove_queue.c +++ b/mm/iob/iob_remove_queue.c @@ -26,6 +26,8 @@ #include +#include +#include #include #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; }