Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH 3/5] misc: fastrpc: take fl->lock when moving mmaps on interrupted invoke
       [not found] <20260724223342.629168-1-srini@kernel.org>
@ 2026-07-24 22:33 ` srini
  2026-07-24 22:33 ` [PATCH 5/5] misc: fastrpc: fix memory leak in fastrpc_channel_ctx_free srini
  1 sibling, 0 replies; 2+ messages in thread
From: srini @ 2026-07-24 22:33 UTC (permalink / raw)
  To: gregkh
  Cc: linux-kernel, Junrui Luo, Yuhao Jiang, stable, Dmitry Baryshkov,
	Srinivas Kandagatla

From: Junrui Luo <moonafterrain@outlook.com>

When an invoke is interrupted by a signal,
wait_for_completion_interruptible() returns -ERESTARTSYS and
fastrpc_internal_invoke() moves every buffer from fl->mmaps onto
cctx->invoke_interrupted_mmaps. This list_del()/list_add_tail() walk
runs without holding fl->lock, the lock that serialises fl->mmaps in
fastrpc_req_mmap() and fastrpc_req_munmap() everywhere else.

Take fl->lock around the move, matching every other fl->mmaps accessor.

Fixes: 76e8e4ace1ed ("misc: fastrpc: Safekeep mmaps on interrupted invoke")
Reported-by: Yuhao Jiang <danisjiang@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Junrui Luo <moonafterrain@outlook.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Srinivas Kandagatla <srini@kernel.org>
---
 drivers/misc/fastrpc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 12dcd2e737c3..c75eafe872cc 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -1305,10 +1305,12 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl,  u32 kernel,
 	}
 
 	if (err == -ERESTARTSYS) {
+		spin_lock(&fl->lock);
 		list_for_each_entry_safe(buf, b, &fl->mmaps, node) {
 			list_del(&buf->node);
 			list_add_tail(&buf->node, &fl->cctx->invoke_interrupted_mmaps);
 		}
+		spin_unlock(&fl->lock);
 	}
 
 	if (err)
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 5/5] misc: fastrpc: fix memory leak in fastrpc_channel_ctx_free
       [not found] <20260724223342.629168-1-srini@kernel.org>
  2026-07-24 22:33 ` [PATCH 3/5] misc: fastrpc: take fl->lock when moving mmaps on interrupted invoke srini
@ 2026-07-24 22:33 ` srini
  1 sibling, 0 replies; 2+ messages in thread
From: srini @ 2026-07-24 22:33 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, Eddie Lin, stable, Ekansh Gupta,
	Srinivas Kandagatla

From: Eddie Lin <eddie.lin@oss.qualcomm.com>

The 'ctx_idr' is initialized but never destroyed when
the channel context is freed, leading to a memory leak.
Add idr_destroy() to properly clean up the IDR resources.

Fixes: f6f9279f2bf0 ("misc: fastrpc: Add Qualcomm fastrpc basic driver model")
Cc: stable@vger.kernel.org
Signed-off-by: Eddie Lin <eddie.lin@oss.qualcomm.com>
Reviewed-by: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>
Signed-off-by: Srinivas Kandagatla <srini@kernel.org>
---
 drivers/misc/fastrpc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index f8cbe30c5d5c..eb6c2a78d3c7 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -492,6 +492,7 @@ static void fastrpc_channel_ctx_free(struct kref *ref)
 
 	cctx = container_of(ref, struct fastrpc_channel_ctx, refcount);
 
+	idr_destroy(&cctx->ctx_idr);
 	kfree(cctx);
 }
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-24 22:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20260724223342.629168-1-srini@kernel.org>
2026-07-24 22:33 ` [PATCH 3/5] misc: fastrpc: take fl->lock when moving mmaps on interrupted invoke srini
2026-07-24 22:33 ` [PATCH 5/5] misc: fastrpc: fix memory leak in fastrpc_channel_ctx_free srini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox