mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 14:53:47 +08:00
serial/ptmx: Add lock to avoid the race condition in ptmx_minor_free
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
committed by
Petro Karashchenko
parent
fdc74dd05f
commit
6cc0388f4f
@@ -299,6 +299,8 @@ void ptmx_minor_free(uint8_t minor)
|
|||||||
int index;
|
int index;
|
||||||
int bitno;
|
int bitno;
|
||||||
|
|
||||||
|
nxsem_wait_uninterruptible(&g_ptmx.px_exclsem);
|
||||||
|
|
||||||
/* Free the address by clearing the associated bit in the px_alloctab[]; */
|
/* Free the address by clearing the associated bit in the px_alloctab[]; */
|
||||||
|
|
||||||
index = minor >> 5;
|
index = minor >> 5;
|
||||||
@@ -313,4 +315,6 @@ void ptmx_minor_free(uint8_t minor)
|
|||||||
{
|
{
|
||||||
g_ptmx.px_next = minor;
|
g_ptmx.px_next = minor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nxsem_post(&g_ptmx.px_exclsem);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user