drivers/uart_rpmsg: add recv lock when received the data from peer
The recv buffer is used both in user thread and rpmsg ept->callback
thread, so add recv lock to protect the recv buffer.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
diff --git a/drivers/serial/uart_rpmsg.c b/drivers/serial/uart_rpmsg.c
index a312848..303ebf8 100644
--- a/drivers/serial/uart_rpmsg.c
+++ b/drivers/serial/uart_rpmsg.c
@@ -384,9 +384,11 @@
{
/* Get write-cmd, there are some data, we need receive them */
+ nxmutex_lock(&dev->recv.lock);
priv->recv_data = data;
uart_recvchars_dma(dev);
priv->recv_data = NULL;
+ nxmutex_unlock(&dev->recv.lock);
header->response = 1;
rpmsg_send(ept, msg, sizeof(*msg));