Skip to content

Commit e8c276d

Browse files
sukrutbgregkh
authored andcommitted
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: 72fa6f7 ("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]>
1 parent 4df1536 commit e8c276d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/misc/fastrpc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1910,7 +1910,8 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp)
19101910
&args[0]);
19111911
if (err) {
19121912
dev_err(dev, "mmap error (len 0x%08llx)\n", buf->size);
1913-
goto err_invoke;
1913+
fastrpc_buf_free(buf);
1914+
return err;
19141915
}
19151916

19161917
/* 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)
19481949

19491950
err_assign:
19501951
fastrpc_req_munmap_impl(fl, buf);
1951-
err_invoke:
1952-
fastrpc_buf_free(buf);
19531952

19541953
return err;
19551954
}

0 commit comments

Comments
 (0)