This is an automated email from the ASF dual-hosted git repository. pkarashchenko pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 6cc0388f4f936617082727c245236f259d85a78e Author: Xiang Xiao <[email protected]> AuthorDate: Sun Feb 6 17:35:13 2022 +0800 serial/ptmx: Add lock to avoid the race condition in ptmx_minor_free Signed-off-by: Xiang Xiao <[email protected]> --- drivers/serial/ptmx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/serial/ptmx.c b/drivers/serial/ptmx.c index 8d96792..1baab82 100644 --- a/drivers/serial/ptmx.c +++ b/drivers/serial/ptmx.c @@ -299,6 +299,8 @@ void ptmx_minor_free(uint8_t minor) int index; int bitno; + nxsem_wait_uninterruptible(&g_ptmx.px_exclsem); + /* Free the address by clearing the associated bit in the px_alloctab[]; */ index = minor >> 5; @@ -313,4 +315,6 @@ void ptmx_minor_free(uint8_t minor) { g_ptmx.px_next = minor; } + + nxsem_post(&g_ptmx.px_exclsem); }
