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:
Xiang Xiao 2022-02-06 17:35:13 +08:00 committed by Petro Karashchenko
parent fdc74dd05f
commit 6cc0388f4f
1 changed files with 4 additions and 0 deletions

View File

@ -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);
}