mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: srini@kernel.org
To: gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org,
	Anandu Krishnan E <anandu.e@oss.qualcomm.com>,
	stable@kernel.org, Srinivas Kandagatla <srini@kernel.org>
Subject: [PATCH 4/6] misc: fastrpc: drop the DSP-response reference on channel removal
Date: Fri, 27 Nov 2026 10:43:52 +0000	[thread overview]
Message-ID: <20261127104354.8452-5-srini@kernel.org> (raw)
In-Reply-To: <20261127104354.8452-1-srini@kernel.org>

From: Anandu Krishnan E <anandu.e@oss.qualcomm.com>

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@kernel.org
Signed-off-by: Anandu Krishnan E <anandu.e@oss.qualcomm.com>
Signed-off-by: Srinivas Kandagatla <srini@kernel.org>
---
 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


  parent reply	other threads:[~2026-11-27 10:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 10:43 [PATCH 0/6] misc: fastrpc: fixes for v7.4 srini
2026-11-27 10:43 ` [PATCH 1/6] misc: fastrpc: fix NULL rpdev dereference when session alloc fails srini
2026-11-27 10:43 ` [PATCH 2/6] misc: fastrpc: fix init ordering race in rpmsg probe srini
2026-11-27 10:43 ` [PATCH 3/6] misc: fastrpc: remove dead context drain in fastrpc_user_free() srini
2026-11-27 10:43 ` srini [this message]
2026-11-27 10:43 ` [PATCH 5/6] misc: fastrpc: fix context leak and hang on signal-interrupted invoke srini
2026-11-27 10:43 ` [PATCH 6/6] misc: fastrpc: avoid duplicate DMA mappings in fastrpc_create_maps() srini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261127104354.8452-5-srini@kernel.org \
    --to=srini@kernel.org \
    --cc=anandu.e@oss.qualcomm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®