[PATCH v3 0/2] Fix two memory leaks in rproc_attach()

Xiaolei Wang posted 2 patches 9 months, 1 week ago
drivers/remoteproc/remoteproc_core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[PATCH v3 0/2] Fix two memory leaks in rproc_attach()
Posted by Xiaolei Wang 9 months, 1 week ago
In the rproc_attach() function, if rproc_handle_resources() returns
failure, the resources requested in imx_rproc_prepare() should be
released, since almost the same thing is done in imx_rproc_prepare() and
rproc_resource_cleanup(), Function rproc_resource_cleanup() is able
to deal with empty lists so it is better to fix the "goto" statements
in rproc_attach(). replace the "unprepare_device" goto statement with
"clean_up_resources" and get rid of the "unprepare_device" label.
and rproc->clean_table should also be released

Changes in v3:
    Update patch1, replace the "unprepare_device" goto statement with
    "clean_up_resources" and get rid of the "unprepare_device" label.

V2:
    Updated the commit log of these two patches
    https://patchwork.kernel.org/project/linux-remoteproc/patch/20250426065348.1234391-2-xiaolei.wang@windriver.com/
    https://patchwork.kernel.org/project/linux-remoteproc/patch/20250426065348.1234391-3-xiaolei.wang@windriver.com/

V1: https://patchwork.kernel.org/project/linux-remoteproc/patch/20250424122252.2777363-1-xiaolei.wang@windriver.com/
    https://patchwork.kernel.org/project/linux-remoteproc/patch/20250424122252.2777363-2-xiaolei.wang@windriver.com/

Xiaolei Wang (2):
  remoteproc: cleanup acquired resources when rproc_handle_resources()
    fails in rproc_attach()
  remoteproc: core: release rproc->clean_table after rproc_attach()
    fails

 drivers/remoteproc/remoteproc_core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

-- 
2.25.1
Re: [PATCH v3 0/2] Fix two memory leaks in rproc_attach()
Posted by Mathieu Poirier 9 months ago
On Wed, Apr 30, 2025 at 05:20:41PM +0800, Xiaolei Wang wrote:
> In the rproc_attach() function, if rproc_handle_resources() returns
> failure, the resources requested in imx_rproc_prepare() should be
> released, since almost the same thing is done in imx_rproc_prepare() and
> rproc_resource_cleanup(), Function rproc_resource_cleanup() is able
> to deal with empty lists so it is better to fix the "goto" statements
> in rproc_attach(). replace the "unprepare_device" goto statement with
> "clean_up_resources" and get rid of the "unprepare_device" label.
> and rproc->clean_table should also be released
> 
> Changes in v3:
>     Update patch1, replace the "unprepare_device" goto statement with
>     "clean_up_resources" and get rid of the "unprepare_device" label.
> 
> V2:
>     Updated the commit log of these two patches
>     https://patchwork.kernel.org/project/linux-remoteproc/patch/20250426065348.1234391-2-xiaolei.wang@windriver.com/
>     https://patchwork.kernel.org/project/linux-remoteproc/patch/20250426065348.1234391-3-xiaolei.wang@windriver.com/
> 
> V1: https://patchwork.kernel.org/project/linux-remoteproc/patch/20250424122252.2777363-1-xiaolei.wang@windriver.com/
>     https://patchwork.kernel.org/project/linux-remoteproc/patch/20250424122252.2777363-2-xiaolei.wang@windriver.com/
> 
> Xiaolei Wang (2):
>   remoteproc: cleanup acquired resources when rproc_handle_resources()
>     fails in rproc_attach()
>   remoteproc: core: release rproc->clean_table after rproc_attach()
>     fails
> 
>  drivers/remoteproc/remoteproc_core.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 

I have applied this patchset.

Thanks,
Mathieu

> -- 
> 2.25.1
>
Re: [PATCH v3 0/2] Fix two memory leaks in rproc_attach()
Posted by Peng Fan 9 months ago
On Wed, Apr 30, 2025 at 05:20:41PM +0800, Xiaolei Wang wrote:
>In the rproc_attach() function, if rproc_handle_resources() returns
>failure, the resources requested in imx_rproc_prepare() should be
>released, since almost the same thing is done in imx_rproc_prepare() and
>rproc_resource_cleanup(), Function rproc_resource_cleanup() is able
>to deal with empty lists so it is better to fix the "goto" statements
>in rproc_attach(). replace the "unprepare_device" goto statement with
>"clean_up_resources" and get rid of the "unprepare_device" label.
>and rproc->clean_table should also be released
>
>Changes in v3:
>    Update patch1, replace the "unprepare_device" goto statement with
>    "clean_up_resources" and get rid of the "unprepare_device" label.
>
>V2:
>    Updated the commit log of these two patches
>    https://patchwork.kernel.org/project/linux-remoteproc/patch/20250426065348.1234391-2-xiaolei.wang@windriver.com/
>    https://patchwork.kernel.org/project/linux-remoteproc/patch/20250426065348.1234391-3-xiaolei.wang@windriver.com/
>
>V1: https://patchwork.kernel.org/project/linux-remoteproc/patch/20250424122252.2777363-1-xiaolei.wang@windriver.com/
>    https://patchwork.kernel.org/project/linux-remoteproc/patch/20250424122252.2777363-2-xiaolei.wang@windriver.com/
>
>Xiaolei Wang (2):
>  remoteproc: cleanup acquired resources when rproc_handle_resources()
>    fails in rproc_attach()
>  remoteproc: core: release rproc->clean_table after rproc_attach()
>    fails
>
> drivers/remoteproc/remoteproc_core.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)

Reviewed-by: Peng Fan <peng.fan@nxp.com>