[PATCH 4/6] misc: fastrpc: drop the DSP-response reference on channel removal
From: srini
Date: Fri Nov 27 2026 - 05:44:36 EST
From: Anandu Krishnan E <anandu.e@xxxxxxxxxxxxxxxx>
fastrpc_invoke_send() takes a second reference on the invoke context
before calling rpmsg_send(), to be dropped later by whichever side
consumes the eventual DSP response: fastrpc_rpmsg_callback() for a
real reply, via schedule_work(&ctx->put_work).
fastrpc_notify_users(), called from fastrpc_rpmsg_remove() when the
rpmsg channel goes away (e.g. on subsystem restart), only completes
each pending context with -EPIPE so its waiter can return - it never
schedules the matching put. Since the channel is gone, no response
will ever arrive to trigger it through the normal callback path
either. Every context that was genuinely in flight (successfully
sent, not yet answered) at the time of an SSR therefore leaks that
second reference, and with it the context, its DMA maps, and the
reference it holds on fl and cctx.
Schedule the same put_work that a real response would have
triggered, exactly as fastrpc_rpmsg_callback() does. rpmsg guarantees
.callback and .remove are mutually exclusive for a given device, so
there is no concurrent real response that could race with this.
Fixes: c68cfb718c8f ("misc: fastrpc: Add support for context Invoke method")
Cc: stable@xxxxxxxxxx
Signed-off-by: Anandu Krishnan E <anandu.e@xxxxxxxxxxxxxxxx>
Signed-off-by: Srinivas Kandagatla <srini@xxxxxxxxxx>
---
drivers/misc/fastrpc.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 60c9d1d0834b..7820c384cde6 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -2544,6 +2544,13 @@ static void fastrpc_notify_users(struct fastrpc_user *user)
list_for_each_entry(ctx, &user->pending, node) {
ctx->retval = -EPIPE;
complete(&ctx->work);
+ /*
+ * fastrpc_invoke_send() took a second reference for the
+ * DSP response that will now never arrive since the
+ * channel is gone; schedule the matching put the same
+ * way a real response would via fastrpc_rpmsg_callback().
+ */
+ schedule_work(&ctx->put_work);
}
spin_unlock(&user->lock);
}
--
2.53.0