aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSukrut Bellary <[email protected]>2024-09-02 15:14:09 +0100
committerGreg Kroah-Hartman <[email protected]>2024-09-03 12:19:31 +0200
commite8c276d4dc0e19ee48385f74426aebc855b49aaf (patch)
tree9a44df077d1c11c53db5ff8b5661cd516dbfe804
parent4df153652cc46545722879415937582028c18af5 (diff)
misc: fastrpc: Fix double free of 'buf' in error path
smatch warning: drivers/misc/fastrpc.c:1926 fastrpc_req_mmap() error: double free of 'buf' In fastrpc_req_mmap() error path, the fastrpc buffer is freed in fastrpc_req_munmap_impl() if unmap is successful. But in the end, there is an unconditional call to fastrpc_buf_free(). So the above case triggers the double free of fastrpc buf. Fixes: 72fa6f7820c4 ("misc: fastrpc: Rework fastrpc_req_munmap") Reviewed-by: Shuah Khan <[email protected]> Reviewed-by: Dan Carpenter <[email protected]> Reviewed-by: Srinivas Kandagatla <[email protected]> Signed-off-by: Sukrut Bellary <[email protected]> Signed-off-by: Srinivas Kandagatla <[email protected]> Cc: stable <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
-rw-r--r--drivers/misc/fastrpc.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 339d126414d4..da87abe93daf 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -1910,7 +1910,8 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp)
&args[0]);
if (err) {
dev_err(dev, "mmap error (len 0x%08llx)\n", buf->size);
- goto err_invoke;
+ fastrpc_buf_free(buf);
+ return err;
}
/* update the buffer to be able to deallocate the memory on the DSP */
@@ -1948,8 +1949,6 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp)
err_assign:
fastrpc_req_munmap_impl(fl, buf);
-err_invoke:
- fastrpc_buf_free(buf);
return err;
}