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 8fc48bdc0cad7892676861ce9af33ef5ea84c463 Author: rongyichang <[email protected]> AuthorDate: Mon Jul 13 16:12:32 2026 +0800 drivers/misc/rpmsgdev_server: reply once to a blocking read The device can call rpmsgdev_read_cb() again before rpmsgdev_read_work() has torn the poll down, because the work queue clears work->worker before running it. The work then runs twice and the client gets two replies for one cookie, the second one after the cookie is gone. Clear the poll callback in rpmsgdev_read_cb() so the work is queued only once. Signed-off-by: rongyichang <[email protected]> Signed-off-by: Bowen Wang <[email protected]> --- drivers/misc/rpmsgdev_server.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/misc/rpmsgdev_server.c b/drivers/misc/rpmsgdev_server.c index 85fd22737a3..363de8e890e 100644 --- a/drivers/misc/rpmsgdev_server.c +++ b/drivers/misc/rpmsgdev_server.c @@ -298,6 +298,17 @@ static void rpmsgdev_read_cb(FAR struct pollfd_s *fds) DEBUGASSERT(fds != NULL); + /* Prevent subsequent poll_notify from re-triggering this callback. + * Without this guard, if the device IRQ fires again before + * rpmsgdev_read_work executes file_poll(teardown), the work will be + * queued a second time (NuttX work_queue allows re-queue when + * worker==NULL during execution), causing the same READ response + * cookie to be sent twice and leading to a use-after-free crash + * on the remote side. + */ + + fds->cb = NULL; + work_queue_wq(g_rpmsgdev_wqueue, &pend->work, rpmsgdev_read_work, fds, 0); }
