This is a note to let you know that I've just added the patch titled misc: fastrpc: Unmap only if buffer is unmapped from DSP to the 6.5-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: misc-fastrpc-unmap-only-if-buffer-is-unmapped-from-dsp.patch and it can be found in the queue-6.5 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 509143385db364c67556a914bef6c9a42fd2c74c Mon Sep 17 00:00:00 2001 From: Ekansh Gupta <quic_ekangupt@xxxxxxxxxxx> Date: Fri, 13 Oct 2023 13:20:07 +0100 Subject: misc: fastrpc: Unmap only if buffer is unmapped from DSP From: Ekansh Gupta <quic_ekangupt@xxxxxxxxxxx> commit 509143385db364c67556a914bef6c9a42fd2c74c upstream. For unmapping any buffer from kernel, it should first be unmapped from DSP. In case unmap from DSP request fails, the map should not be removed from kernel as it might lead to SMMU faults and other memory issues. Fixes: 5c1b97c7d7b7 ("misc: fastrpc: add support for FASTRPC_IOCTL_MEM_MAP/UNMAP") Cc: stable <stable@xxxxxxxxxx> Signed-off-by: Ekansh Gupta <quic_ekangupt@xxxxxxxxxxx> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@xxxxxxxxxx> Link: https://lore.kernel.org/r/20231013122007.174464-5-srinivas.kandagatla@xxxxxxxxxx Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/misc/fastrpc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -1980,11 +1980,13 @@ static int fastrpc_req_mem_unmap_impl(st sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_MEM_UNMAP, 1, 0); err = fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE, sc, &args[0]); - fastrpc_map_put(map); - if (err) + if (err) { dev_err(dev, "unmmap\tpt fd = %d, 0x%09llx error\n", map->fd, map->raddr); + return err; + } + fastrpc_map_put(map); - return err; + return 0; } static int fastrpc_req_mem_unmap(struct fastrpc_user *fl, char __user *argp) Patches currently in stable-queue which might be from quic_ekangupt@xxxxxxxxxxx are queue-6.5/misc-fastrpc-reset-metadata-buffer-to-avoid-incorrect-free.patch queue-6.5/misc-fastrpc-unmap-only-if-buffer-is-unmapped-from-dsp.patch queue-6.5/misc-fastrpc-clean-buffers-on-remote-invocation-failures.patch queue-6.5/misc-fastrpc-free-dma-handles-for-rpc-calls-with-no-arguments.patch