2023-10-10 05:40:02

by Ekansh Gupta

[permalink] [raw]
Subject: [PATCH v1] misc: fastrpc: Unmap only if buffer is unmapped from DSP

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 <[email protected]>
Signed-off-by: Ekansh Gupta <[email protected]>
---
drivers/misc/fastrpc.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index a66b7c1..130605c 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -1983,11 +1983,13 @@ static int fastrpc_req_mem_unmap_impl(struct fastrpc_user *fl, struct fastrpc_me
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)
--
2.7.4


2023-10-10 10:22:33

by Srinivas Kandagatla

[permalink] [raw]
Subject: Re: [PATCH v1] misc: fastrpc: Unmap only if buffer is unmapped from DSP


On Tue, 10 Oct 2023 11:09:27 +0530, Ekansh Gupta wrote:
> 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.
>
>

Applied, thanks!

[1/1] misc: fastrpc: Unmap only if buffer is unmapped from DSP
commit: d4ed3ed0086f03f210a6e171a581c332dde9e961

Best regards,
--
Srinivas Kandagatla <[email protected]>