This is an automated email from the ASF dual-hosted git repository. GUIDINGLI pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 35a8024f9a63a4e1049bbf5be3ab8687566530a1 Author: Xiang Xiao <[email protected]> AuthorDate: Sun Apr 20 13:48:49 2025 +0800 drivers/misc/rpmsgdev: reset the bound count when the device goes away priv->wait counts the binding of the endpoint: ns_bound posts it and every request waits for it and posts it back. rpmsgdev_device_destroy() destroyed the endpoint but left the count at 1, so a request issued after that used the destroyed endpoint instead of waiting for the next binding. Take the count back before destroying the endpoint. Also destroy the semaphore used by rpmsgdev_wait(). Signed-off-by: Xiang Xiao <[email protected]> --- drivers/misc/rpmsgdev.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/misc/rpmsgdev.c b/drivers/misc/rpmsgdev.c index 19b77ee7732..d3f648649a0 100644 --- a/drivers/misc/rpmsgdev.c +++ b/drivers/misc/rpmsgdev.c @@ -342,19 +342,19 @@ static int rpmsgdev_wait(FAR struct file *filep, pollevent_t events) fds.cb = rpmsgdev_wait_cb; events |= POLLERR | POLLHUP; - while (1) + for (; ; ) { ret = rpmsgdev_poll(filep, &fds, true); if (ret < 0) { - return ret; + break; } ret = nxsem_wait(&sem); rpmsgdev_poll(filep, &fds, false); if (ret < 0) { - return ret; + break; } if ((fds.revents & events) != 0) @@ -363,6 +363,7 @@ static int rpmsgdev_wait(FAR struct file *filep, pollevent_t events) } } + nxsem_destroy(&sem); return ret; } @@ -755,7 +756,7 @@ static int rpmsgdev_poll(FAR struct file *filep, FAR struct pollfd_s *fds, static FAR void *rpmsgdev_get_tx_payload_buffer(FAR struct rpmsgdev_s *priv, FAR uint32_t *len) { - int sval; + int sval = 0; nxsem_get_value(&priv->wait, &sval); if (sval <= 0) @@ -826,7 +827,7 @@ static int rpmsgdev_send_recv(FAR struct rpmsgdev_s *priv, if (ret < 0) { - if (copy == false) + if (!copy) { rpmsg_release_tx_buffer(&priv->ept, msg); } @@ -1069,6 +1070,7 @@ static void rpmsgdev_device_destroy(FAR struct rpmsg_device *rdev, if (strcmp(priv->remotecpu, rpmsg_get_cpuname(rdev)) == 0) { + rpmsg_wait(&priv->ept, &priv->wait); rpmsg_destroy_ept(&priv->ept); } } @@ -1186,7 +1188,7 @@ int rpmsgdev_register(FAR const char *remotecpu, FAR const char *remotepath, goto fail_with_rpmsg; } - return OK; + return 0; fail_with_rpmsg: rpmsg_unregister_callback(dev,
