Skip to content

Commit 4753cc3

Browse files
sukrutbgregkh
authored andcommitted
misc: fastrpc: Fix double free of 'buf' in error path
commit e8c276d upstream. 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 <skhan@linuxfoundation.org> Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Sukrut Bellary <sukrut.bellary@linux.com> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Cc: stable <stable@kernel.org> Link: https://lore.kernel.org/r/20240902141409.70371-2-srinivas.kandagatla@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 2753722 commit 4753cc3

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

drivers/misc/fastrpc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,7 +1774,8 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp)
17741774
&args[0]);
17751775
if (err) {
17761776
dev_err(dev, "mmap error (len 0x%08llx)\n", buf->size);
1777-
goto err_invoke;
1777+
fastrpc_buf_free(buf);
1778+
return err;
17781779
}
17791780

17801781
/* update the buffer to be able to deallocate the memory on the DSP */
@@ -1799,8 +1800,6 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp)
17991800

18001801
err_assign:
18011802
fastrpc_req_munmap_impl(fl, buf);
1802-
err_invoke:
1803-
fastrpc_buf_free(buf);
18041803

18051804
return err;
18061805
}

0 commit comments

Comments
 (0)