]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
misc: fastrpc: Clean buffers on remote invocation failures
authorEkansh Gupta <quic_ekangupt@quicinc.com>
Fri, 13 Oct 2023 12:20:06 +0000 (13:20 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 Nov 2023 08:36:58 +0000 (09:36 +0100)
commit 1c8093591d1e372d700fe65423e7315a8ecf721b upstream.

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.

Fixes: c68cfb718c8f ("misc: fastrpc: Add support for context Invoke method")
Cc: stable <stable@kernel.org>
Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20231013122007.174464-4-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/fastrpc.c

index b251e4a109893f66c33d4ec4c1d9767e7e073e1e..94ec3175f22dc4d90b2bd693b1aaaa020cc83a74 100644 (file)
@@ -1175,11 +1175,6 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl,  u32 kernel,
                err = wait_for_completion_interruptible(&ctx->work);
        }
 
-       if (err)
-               goto bail;
-
-       /* Check the response from remote dsp */
-       err = ctx->retval;
        if (err)
                goto bail;
 
@@ -1190,6 +1185,11 @@ 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;
+
 bail:
        if (err != -ERESTARTSYS && err != -ETIMEDOUT) {
                /* We are done with this compute context */