<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/drivers/misc/fastrpc.c, branch v5.4.90</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.4.90</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.4.90'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2020-06-24T15:50:13Z</updated>
<entry>
<title>misc: fastrpc: fix potential fastrpc_invoke_ctx leak</title>
<updated>2020-06-24T15:50:13Z</updated>
<author>
<name>Srinivas Kandagatla</name>
<email>srinivas.kandagatla@linaro.org</email>
</author>
<published>2020-05-12T11:09:30Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=08f396eb02c8e5adf8c933414627879ae39876e5'/>
<id>urn:sha1:08f396eb02c8e5adf8c933414627879ae39876e5</id>
<content type='text'>
[ Upstream commit 74003385cf716f1b88cc7753ca282f5493f204a2 ]

fastrpc_invoke_ctx can have refcount of 2 in error path where
rpmsg_send() fails to send invoke message. decrement the refcount
properly in the error path to fix this leak.

This also fixes below static checker warning:

drivers/misc/fastrpc.c:990 fastrpc_internal_invoke()
warn: 'ctx-&gt;refcount.refcount.ref.counter' not decremented on lines: 990.

Fixes: c68cfb718c8f ("misc: fastrpc: Add support for context")
Reported-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Signed-off-by: Srinivas Kandagatla &lt;srinivas.kandagatla@linaro.org&gt;
Reviewed-by: Bjorn Andersson &lt;bjorn.andersson@linaro.org&gt;
Link: https://lore.kernel.org/r/20200512110930.2550-1-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>misc: fastrpc: Fix an incomplete memory release in fastrpc_rpmsg_probe()</title>
<updated>2020-06-24T15:50:13Z</updated>
<author>
<name>Srinivas Kandagatla</name>
<email>srinivas.kandagatla@linaro.org</email>
</author>
<published>2020-05-11T16:27:22Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=8d8991bb2bf042d46fe277d7a52adccdfc98b8eb'/>
<id>urn:sha1:8d8991bb2bf042d46fe277d7a52adccdfc98b8eb</id>
<content type='text'>
[ Upstream commit 0978de9fc7335c73934ab8fac189fb4cb3f23191 ]

fastrpc_channel_ctx is not freed if misc_register() fails, this would
lead to a memory leak. Fix this leak by adding kfree in misc_register()
error path.

Fixes: 278d56f970ae ("misc: fastrpc: Reference count channel context")
Signed-off-by: Srinivas Kandagatla &lt;srinivas.kandagatla@linaro.org&gt;
Reviewed-by: Bjorn Andersson &lt;bjorn.andersson@linaro.org&gt;
Link: https://lore.kernel.org/r/20200511162722.2552-1-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>misc: fastrpc: fix memory leak from miscdev-&gt;name</title>
<updated>2019-12-31T15:43:58Z</updated>
<author>
<name>Srinivas Kandagatla</name>
<email>srinivas.kandagatla@linaro.org</email>
</author>
<published>2019-10-09T14:41:20Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=6083bbaee80f6bc4e489c3648db9a23175b0c4a9'/>
<id>urn:sha1:6083bbaee80f6bc4e489c3648db9a23175b0c4a9</id>
<content type='text'>
[ Upstream commit 2d10d2d170723e9278282458a6704552dcb77eac ]

Fix a memory leak in miscdev-&gt;name by using devm_variant

Orignally reported by kmemleak:
    [&lt;ffffff80088b74d8&gt;] kmemleak_alloc+0x50/0x84
    [&lt;ffffff80081e015c&gt;] __kmalloc_track_caller+0xe8/0x168
    [&lt;ffffff8008371ab0&gt;] kvasprintf+0x78/0x100
    [&lt;ffffff8008371c6c&gt;] kasprintf+0x50/0x74
    [&lt;ffffff8008507f2c&gt;] fastrpc_rpmsg_probe+0xd8/0x20c
    [&lt;ffffff80086b63b4&gt;] rpmsg_dev_probe+0xa8/0x148
    [&lt;ffffff80084de50c&gt;] really_probe+0x208/0x248
    [&lt;ffffff80084de2dc&gt;] driver_probe_device+0x98/0xc0
    [&lt;ffffff80084dec6c&gt;] __device_attach_driver+0x9c/0xac
    [&lt;ffffff80084dca8c&gt;] bus_for_each_drv+0x60/0x8c
    [&lt;ffffff80084de64c&gt;] __device_attach+0x8c/0x100
    [&lt;ffffff80084de6e0&gt;] device_initial_probe+0x20/0x28
    [&lt;ffffff80084dcbd0&gt;] bus_probe_device+0x34/0x7c
    [&lt;ffffff80084da32c&gt;] device_add+0x420/0x498
    [&lt;ffffff80084da680&gt;] device_register+0x24/0x2c

Signed-off-by: Srinivas Kandagatla &lt;srinivas.kandagatla@linaro.org&gt;
Reviewed-by: Bjorn Andersson &lt;bjorn.andersson@linaro.org&gt;
Link: https://lore.kernel.org/r/20191009144123.24583-3-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>misc: fastrpc: prevent memory leak in fastrpc_dma_buf_attach</title>
<updated>2019-10-04T16:22:14Z</updated>
<author>
<name>Navid Emamdoost</name>
<email>navid.emamdoost@gmail.com</email>
</author>
<published>2019-09-25T15:27:41Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=fc739a058d99c9297ef6bfd923b809d85855b9a9'/>
<id>urn:sha1:fc739a058d99c9297ef6bfd923b809d85855b9a9</id>
<content type='text'>
In fastrpc_dma_buf_attach if dma_get_sgtable fails the allocated memory
for a should be released.

Signed-off-by: Navid Emamdoost &lt;navid.emamdoost@gmail.com&gt;
Link: https://lore.kernel.org/r/20190925152742.16258-1-navid.emamdoost@gmail.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>misc: fastrpc: free dma buf scatter list</title>
<updated>2019-09-04T11:35:11Z</updated>
<author>
<name>Srinivas Kandagatla</name>
<email>srinivas.kandagatla@linaro.org</email>
</author>
<published>2019-08-29T09:29:26Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=cf61860e6b090bea4050c5688566bfe357cacd11'/>
<id>urn:sha1:cf61860e6b090bea4050c5688566bfe357cacd11</id>
<content type='text'>
dma buf scatter list is never freed, free it!

Orignally detected by kmemleak:
  backtrace:
    [&lt;ffffff80088b7658&gt;] kmemleak_alloc+0x50/0x84
    [&lt;ffffff8008373284&gt;] sg_kmalloc+0x38/0x60
    [&lt;ffffff8008373144&gt;] __sg_alloc_table+0x60/0x110
    [&lt;ffffff800837321c&gt;] sg_alloc_table+0x28/0x58
    [&lt;ffffff800837336c&gt;] __sg_alloc_table_from_pages+0xc0/0x1ac
    [&lt;ffffff800837346c&gt;] sg_alloc_table_from_pages+0x14/0x1c
    [&lt;ffffff8008097a3c&gt;] __iommu_get_sgtable+0x5c/0x8c
    [&lt;ffffff800850a1d0&gt;] fastrpc_dma_buf_attach+0x84/0xf8
    [&lt;ffffff80085114bc&gt;] dma_buf_attach+0x70/0xc8
    [&lt;ffffff8008509efc&gt;] fastrpc_map_create+0xf8/0x1e8
    [&lt;ffffff80085086f4&gt;] fastrpc_device_ioctl+0x508/0x900
    [&lt;ffffff80082428c8&gt;] compat_SyS_ioctl+0x128/0x200
    [&lt;ffffff80080832c4&gt;] el0_svc_naked+0x34/0x38
    [&lt;ffffffffffffffff&gt;] 0xffffffffffffffff

Reported-by: Mayank Chopra &lt;mak.chopra@codeaurora.org&gt;
Signed-off-by: Srinivas Kandagatla &lt;srinivas.kandagatla@linaro.org&gt;
Link: https://lore.kernel.org/r/20190829092926.12037-6-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>misc: fastrpc: fix double refcounting on dmabuf</title>
<updated>2019-09-04T11:35:11Z</updated>
<author>
<name>Srinivas Kandagatla</name>
<email>srinivas.kandagatla@linaro.org</email>
</author>
<published>2019-08-29T09:29:25Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=5672ff4dc3898b6b74c114de2f53e667ab5a0327'/>
<id>urn:sha1:5672ff4dc3898b6b74c114de2f53e667ab5a0327</id>
<content type='text'>
dma buf refcount has to be done by the driver which is going to use the fd.
This driver already does refcount on the dmabuf fd if its actively using it
but also does an additional refcounting via extra ioctl.
This additional refcount can lead to memory leak in cases where the
applications fail to call the ioctl to decrement the refcount.

So remove this extra refcount in the ioctl

More info of dma buf usage at drivers/dma-buf/dma-buf.c

Reported-by: Mayank Chopra &lt;mak.chopra@codeaurora.org&gt;
Reported-by: Jorge Ramirez-Ortiz &lt;jorge.ramirez-ortiz@linaro.org&gt;
Tested-by: Jorge Ramirez-Ortiz &lt;jorge.ramirez-ortiz@linaro.org&gt;
Signed-off-by: Srinivas Kandagatla &lt;srinivas.kandagatla@linaro.org&gt;
Link: https://lore.kernel.org/r/20190829092926.12037-5-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>misc: fastrpc: remove unused definition</title>
<updated>2019-09-04T11:35:11Z</updated>
<author>
<name>Jorge Ramirez-Ortiz</name>
<email>jorge.ramirez-ortiz@linaro.org</email>
</author>
<published>2019-08-29T09:29:24Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=15fe27f3162ee47c0363cd8cf53b351823479063'/>
<id>urn:sha1:15fe27f3162ee47c0363cd8cf53b351823479063</id>
<content type='text'>
Remove unused INIT_MEMLEN_MAX define.

Signed-off-by: Jorge Ramirez-Ortiz &lt;jorge.ramirez-ortiz@linaro.org&gt;
Signed-off-by: Abhinav Asati &lt;asatiabhi@codeaurora.org&gt;
Signed-off-by: Vamsi Singamsetty &lt;vamssi@codeaurora.org&gt;
Signed-off-by: Srinivas Kandagatla &lt;srinivas.kandagatla@linaro.org&gt;
Link: https://lore.kernel.org/r/20190829092926.12037-4-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>misc: fastrpc: Don't reference rpmsg_device after remove</title>
<updated>2019-09-04T11:35:10Z</updated>
<author>
<name>Bjorn Andersson</name>
<email>bjorn.andersson@linaro.org</email>
</author>
<published>2019-08-29T09:29:23Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=2e369878bd4399283f2950dc4947cf44c857dd74'/>
<id>urn:sha1:2e369878bd4399283f2950dc4947cf44c857dd74</id>
<content type='text'>
As fastrpc_rpmsg_remove() returns the rpdev of the channel context is no
longer a valid object, so ensure to update the channel context to no
longer reference the old object and guard in the invoke code path
against dereferencing it.

Signed-off-by: Bjorn Andersson &lt;bjorn.andersson@linaro.org&gt;
Signed-off-by: Mayank Chopra &lt;mak.chopra@codeaurora.org&gt;
Signed-off-by: Abhinav Asati &lt;asatiabhi@codeaurora.org&gt;
Signed-off-by: Vamsi Singamsetty &lt;vamssi@codeaurora.org&gt;
Signed-off-by: Srinivas Kandagatla &lt;srinivas.kandagatla@linaro.org&gt;
Link: https://lore.kernel.org/r/20190829092926.12037-3-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>misc: fastrpc: Reference count channel context</title>
<updated>2019-09-04T11:35:10Z</updated>
<author>
<name>Bjorn Andersson</name>
<email>bjorn.andersson@linaro.org</email>
</author>
<published>2019-08-29T09:29:22Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=278d56f970ae6e0bcda8970e78e088e3efe43da8'/>
<id>urn:sha1:278d56f970ae6e0bcda8970e78e088e3efe43da8</id>
<content type='text'>
The channel context is referenced from the fastrpc user and might as
user space holds the file descriptor open outlive the fastrpc device,
which is removed when the remote processor is shutting down.

Reference count the channel context in order to retain this object until
all references has been relinquished.

Signed-off-by: Bjorn Andersson &lt;bjorn.andersson@linaro.org&gt;
Signed-off-by: Mayank Chopra &lt;mak.chopra@codeaurora.org&gt;
Signed-off-by: Abhinav Asati &lt;asatiabhi@codeaurora.org&gt;
Signed-off-by: Vamsi Singamsetty &lt;vamssi@codeaurora.org&gt;
Signed-off-by: Srinivas Kandagatla &lt;srinivas.kandagatla@linaro.org&gt;
Link: https://lore.kernel.org/r/20190829092926.12037-2-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>misc: fastrpc: fix memory leak when out of memory</title>
<updated>2019-07-25T12:46:17Z</updated>
<author>
<name>Jorge Ramirez-Ortiz</name>
<email>jorge.ramirez-ortiz@linaro.org</email>
</author>
<published>2019-07-05T08:13:03Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=41db5f8397eee75afff82655a4884b5786a1d302'/>
<id>urn:sha1:41db5f8397eee75afff82655a4884b5786a1d302</id>
<content type='text'>
Do the necessary house-keeping if the allocated memory wont be used

Signed-off-by: Jorge Ramirez-Ortiz &lt;jorge.ramirez-ortiz@linaro.org&gt;
Link: https://lore.kernel.org/r/20190705081303.14170-1-jorge.ramirez-ortiz@linaro.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
</feed>
