Message ID | 20230602113602.1271695-1-sukrut.bellary@linux.com |
---|---|
State | Accepted |
Commit | e8c276d4dc0e19ee48385f74426aebc855b49aaf |
Headers | show |
Series | [v2] misc: fastrpc: Fix double free of 'buf' in error path | expand |
On Fri, 02 Jun 2023 04:36:02 -0700, Sukrut Bellary wrote: > 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. > > [...] Applied, thanks! [1/1] misc: fastrpc: Fix double free of 'buf' in error path commit: 5b3006fffce89706a12741d7f657869ca2be1640 Best regards,
On Mon, Jun 12, 2023 at 11:58:01AM +0100, Srinivas Kandagatla wrote: > > On Fri, 02 Jun 2023 04:36:02 -0700, Sukrut Bellary wrote: > > 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. > > > > [...] > > Applied, thanks! > > [1/1] misc: fastrpc: Fix double free of 'buf' in error path > commit: 5b3006fffce89706a12741d7f657869ca2be1640 > This patch wasn't actually applied. I'm not sure what went wrong. regards, dan carpenter
On 15/08/2024 10:25, Dan Carpenter wrote: > On Mon, Jun 12, 2023 at 11:58:01AM +0100, Srinivas Kandagatla wrote: >> >> On Fri, 02 Jun 2023 04:36:02 -0700, Sukrut Bellary wrote: >>> 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. >>> >>> [...] >> >> Applied, thanks! >> >> [1/1] misc: fastrpc: Fix double free of 'buf' in error path >> commit: 5b3006fffce89706a12741d7f657869ca2be1640 >> > > This patch wasn't actually applied. I'm not sure what went wrong. Am not sure either, its now applied! thanks for checking this. --srini > > regards, > dan carpenter >
On Fri, 02 Jun 2023 04:36:02 -0700, Sukrut Bellary wrote: > 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. > > [...] Applied, thanks! [1/1] misc: fastrpc: Fix double free of 'buf' in error path commit: b056e4e23acbbbf12fa011caa781f7cecbd5b311 Best regards,
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index f48466960f1b..b3b520fcfb75 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -1882,7 +1882,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 */ @@ -1922,8 +1923,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; }