You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/02/06 15:19:35 UTC

[incubator-nuttx] 01/02: serial/ptmx: Add lock to avoid the race condition in ptmx_minor_free

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 <xi...@xiaomi.com>
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 <xi...@xiaomi.com>
---
 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);
 }