]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
rpmsg: char: Fix use-after-free on probe error path
authorYuho Choi <dbgh9129@gmail.com>
Mon, 1 Jun 2026 18:32:47 +0000 (14:32 -0400)
committerMathieu Poirier <mathieu.poirier@linaro.org>
Thu, 4 Jun 2026 17:58:37 +0000 (11:58 -0600)
commit1ff3f528e67d20e2b1483dcaba899dc7832b2e6b
treecd346b88200fa9dd7ca1ed31dd0b6a50cb19e1e2
parent254f49634ee16a731174d2ae34bc50bd5f45e731
rpmsg: char: Fix use-after-free on probe error path

rpmsg_chrdev_probe() stores the newly allocated eptdev in the default
endpoint's priv pointer before calling rpmsg_chrdev_eptdev_add(). If
rpmsg_chrdev_eptdev_add() then fails, its error path frees eptdev while
the default endpoint may still dispatch callbacks with the stale priv
pointer.

Avoid publishing eptdev through the default endpoint until
rpmsg_chrdev_eptdev_add() succeeds. Messages received before the priv
pointer is published should be ignored by rpmsg_ept_cb(). Flow-control
updates can hit rpmsg_ept_flow_cb() in the same window, so make both
callbacks return success when priv is NULL.

Fixes: bc69d1066569 ("rpmsg: char: Introduce the "rpmsg-raw" channel")
Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20260601183247.1962010-1-dbgh9129@gmail.com
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
drivers/rpmsg/rpmsg_char.c