Skip to content

Commit

Permalink
drivers/serial: fix deadlock when executing rexec in a user task
Browse files Browse the repository at this point in the history
CPU0                                                  CPU1
task:nsh_main     task:user_app                       rexecd
nsh_consolemain	  system
uart_read         rexec				      ---
got recv.lock     poll			              ---
	          uart_poll       rpmsg_socket_poll   rpmsg_socket_close
wait recvsem      get recv.lock   poll_notify
                  deadlock        routine work

the error accurs in CPU0 when waiting console input

resolve: unlock recv.lock when waiting recvsem

Signed-off-by: fangpeina <[email protected]>
  • Loading branch information
fangpeina authored and xiaoxiang781216 committed Sep 14, 2024
1 parent 10e7d8f commit 11f06eb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/serial/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -1052,15 +1052,19 @@ static ssize_t uart_read(FAR struct file *filep,
dev->minrecv = MIN(buflen - recvd, dev->minread - recvd);
if (dev->timeout)
{
nxmutex_unlock(&dev->recv.lock);
ret = nxsem_tickwait(&dev->recvsem,
DSEC2TICK(dev->timeout));
}
else
#endif
{
nxmutex_unlock(&dev->recv.lock);
ret = nxsem_wait(&dev->recvsem);
}

nxmutex_lock(&dev->recv.lock);

#ifdef CONFIG_SERIAL_TERMIOS
dev->minrecv = dev->minread;
#endif
Expand Down

0 comments on commit 11f06eb

Please sign in to comment.