diff mbox series

[v1] misc: fastrpc: Clean buffers on remote invocation failures

Message ID 1693464082-24095-1-git-send-email-quic_ekangupt@quicinc.com
State Superseded
Headers show
Series [v1] misc: fastrpc: Clean buffers on remote invocation failures | expand

Commit Message

Ekansh Gupta Aug. 31, 2023, 6:41 a.m. UTC
With current design, buffers and dma handles are not freed in case
of remote invocation failures returned from DSP. This could result
in buffer leakings and dma handle pointing to wrong memory in the
fastrpc kernel. Adding changes to clean buffers and dma handles
even when remote invocation to DSP returns failures.

Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
---
 drivers/misc/fastrpc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Greg Kroah-Hartman Sept. 28, 2023, 1:08 p.m. UTC | #1
On Thu, Aug 31, 2023 at 12:11:22PM +0530, Ekansh Gupta wrote:
> With current design, buffers and dma handles are not freed in case
> of remote invocation failures returned from DSP. This could result
> in buffer leakings and dma handle pointing to wrong memory in the
> fastrpc kernel. Adding changes to clean buffers and dma handles
> even when remote invocation to DSP returns failures.
> 
> Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>

What commit id does this fix?

thanks,

greg k-h
diff mbox series

Patch

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 9666d28..299375f 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -1176,11 +1176,6 @@  static int fastrpc_internal_invoke(struct fastrpc_user *fl,  u32 kernel,
 	if (err)
 		goto bail;
 
-	/* Check the response from remote dsp */
-	err = ctx->retval;
-	if (err)
-		goto bail;
-
 	if (ctx->nscalars) {
 		/* make sure that all memory writes by DSP are seen by CPU */
 		dma_rmb();
@@ -1190,6 +1185,11 @@  static int fastrpc_internal_invoke(struct fastrpc_user *fl,  u32 kernel,
 			goto bail;
 	}
 
+	/* Check the response from remote dsp */
+	err = ctx->retval;
+	if (err)
+		goto bail;
+
 bail:
 	if (err != -ERESTARTSYS && err != -ETIMEDOUT) {
 		/* We are done with this compute context */