linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fpga: Fix memory leak in build_info_create_dev
@ 2022-05-11  6:44 Miaoqian Lin
  2022-05-11  7:50 ` Xu Yilun
  0 siblings, 1 reply; 2+ messages in thread
From: Miaoqian Lin @ 2022-05-11  6:44 UTC (permalink / raw)
  To: Wu Hao, Tom Rix, Moritz Fischer, Xu Yilun, Tim Whisonant,
	Enno Luebbers, Alan Tull, Shiva Rao, Greg Kroah-Hartman,
	linux-fpga, linux-kernel
  Cc: linmq006

platform_device_alloc() create a platform device object.
we should call platform_device_put() in error path to
release the resource.

Fixes: 543be3d8c999 ("fpga: add device feature list support")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/fpga/dfl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
index 599bb21d86af..f0b945bd975f 100644
--- a/drivers/fpga/dfl.c
+++ b/drivers/fpga/dfl.c
@@ -879,8 +879,10 @@ build_info_create_dev(struct build_feature_devs_info *binfo,
 	INIT_LIST_HEAD(&binfo->sub_features);
 
 	fdev->id = dfl_id_alloc(type, &fdev->dev);
-	if (fdev->id < 0)
+	if (fdev->id < 0) {
+		platform_device_put(fdev);
 		return fdev->id;
+	}
 
 	fdev->dev.parent = &binfo->cdev->region->dev;
 	fdev->dev.devt = dfl_get_devt(dfl_devs[type].devt_type, fdev->id);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] fpga: Fix memory leak in build_info_create_dev
  2022-05-11  6:44 [PATCH] fpga: Fix memory leak in build_info_create_dev Miaoqian Lin
@ 2022-05-11  7:50 ` Xu Yilun
  0 siblings, 0 replies; 2+ messages in thread
From: Xu Yilun @ 2022-05-11  7:50 UTC (permalink / raw)
  To: Miaoqian Lin
  Cc: Wu Hao, Tom Rix, Moritz Fischer, Tim Whisonant, Enno Luebbers,
	Alan Tull, Shiva Rao, Greg Kroah-Hartman, linux-fpga,
	linux-kernel

On Wed, May 11, 2022 at 10:44:00AM +0400, Miaoqian Lin wrote:
> platform_device_alloc() create a platform device object.
> we should call platform_device_put() in error path to
> release the resource.
> 
> Fixes: 543be3d8c999 ("fpga: add device feature list support")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---
>  drivers/fpga/dfl.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
> index 599bb21d86af..f0b945bd975f 100644
> --- a/drivers/fpga/dfl.c
> +++ b/drivers/fpga/dfl.c
> @@ -879,8 +879,10 @@ build_info_create_dev(struct build_feature_devs_info *binfo,
>  	INIT_LIST_HEAD(&binfo->sub_features);
>  
>  	fdev->id = dfl_id_alloc(type, &fdev->dev);
> -	if (fdev->id < 0)
> +	if (fdev->id < 0) {
> +		platform_device_put(fdev);
>  		return fdev->id;
> +	}

The build_info_free() will finally put the fdev, is it?

Thanks
Yilun

>  
>  	fdev->dev.parent = &binfo->cdev->region->dev;
>  	fdev->dev.devt = dfl_get_devt(dfl_devs[type].devt_type, fdev->id);
> -- 
> 2.25.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-11  7:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-11  6:44 [PATCH] fpga: Fix memory leak in build_info_create_dev Miaoqian Lin
2022-05-11  7:50 ` Xu Yilun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).