linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] clk: imx: scu: fix memleak on platform_device_add() fails
@ 2022-09-14  3:32 Lin Yujun
  2022-09-26  9:13 ` linyujun (C)
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Lin Yujun @ 2022-09-14  3:32 UTC (permalink / raw)
  To: abelvesa, mturquette, sboyd, shawnguo, s.hauer, kernel, festevam,
	linux-imx, aisheng.dong
  Cc: linux-clk, linux-arm-kernel, linux-kernel

No error handling is performed when platform_device_add()
fails. Add error processing before return, and modified
the return value.

Fixes: 77d8f3068c63 ("clk: imx: scu: add two cells binding support")
Signed-off-by: Lin Yujun <linyujun809@huawei.com>
---
 drivers/clk/imx/clk-scu.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/imx/clk-scu.c b/drivers/clk/imx/clk-scu.c
index c56e406138db..1e6870f3671f 100644
--- a/drivers/clk/imx/clk-scu.c
+++ b/drivers/clk/imx/clk-scu.c
@@ -695,7 +695,11 @@ struct clk_hw *imx_clk_scu_alloc_dev(const char *name,
 		pr_warn("%s: failed to attached the power domain %d\n",
 			name, ret);
 
-	platform_device_add(pdev);
+	ret = platform_device_add(pdev);
+	if (ret) {
+		platform_device_put(pdev);
+		return ERR_PTR(ret);
+	}
 
 	/* For API backwards compatiblilty, simply return NULL for success */
 	return NULL;
-- 
2.17.1


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

* Re: [PATCH -next] clk: imx: scu: fix memleak on platform_device_add() fails
  2022-09-14  3:32 [PATCH -next] clk: imx: scu: fix memleak on platform_device_add() fails Lin Yujun
@ 2022-09-26  9:13 ` linyujun (C)
  2022-10-01  0:06 ` Stephen Boyd
  2022-10-01  0:07 ` Stephen Boyd
  2 siblings, 0 replies; 4+ messages in thread
From: linyujun (C) @ 2022-09-26  9:13 UTC (permalink / raw)
  To: abelvesa, mturquette, sboyd, shawnguo, s.hauer, kernel, festevam,
	linux-imx, aisheng.dong
  Cc: linux-clk, linux-arm-kernel, linux-kernel

kindly ping

在 2022/9/14 11:32, Lin Yujun 写道:
> No error handling is performed when platform_device_add()
> fails. Add error processing before return, and modified
> the return value.
>
> Fixes: 77d8f3068c63 ("clk: imx: scu: add two cells binding support")
> Signed-off-by: Lin Yujun <linyujun809@huawei.com>
> ---
>   drivers/clk/imx/clk-scu.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/clk/imx/clk-scu.c b/drivers/clk/imx/clk-scu.c
> index c56e406138db..1e6870f3671f 100644
> --- a/drivers/clk/imx/clk-scu.c
> +++ b/drivers/clk/imx/clk-scu.c
> @@ -695,7 +695,11 @@ struct clk_hw *imx_clk_scu_alloc_dev(const char *name,
>   		pr_warn("%s: failed to attached the power domain %d\n",
>   			name, ret);
>   
> -	platform_device_add(pdev);
> +	ret = platform_device_add(pdev);
> +	if (ret) {
> +		platform_device_put(pdev);
> +		return ERR_PTR(ret);
> +	}
>   
>   	/* For API backwards compatiblilty, simply return NULL for success */
>   	return NULL;

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

* Re: [PATCH -next] clk: imx: scu: fix memleak on platform_device_add() fails
  2022-09-14  3:32 [PATCH -next] clk: imx: scu: fix memleak on platform_device_add() fails Lin Yujun
  2022-09-26  9:13 ` linyujun (C)
@ 2022-10-01  0:06 ` Stephen Boyd
  2022-10-01  0:07 ` Stephen Boyd
  2 siblings, 0 replies; 4+ messages in thread
From: Stephen Boyd @ 2022-10-01  0:06 UTC (permalink / raw)
  To: Lin Yujun, abelvesa, aisheng.dong, festevam, kernel, linux-imx,
	mturquette, s.hauer, shawnguo
  Cc: linux-clk, linux-arm-kernel, linux-kernel

Quoting Lin Yujun (2022-09-13 20:32:06)
> No error handling is performed when platform_device_add()
> fails. Add error processing before return, and modified
> the return value.
> 
> Fixes: 77d8f3068c63 ("clk: imx: scu: add two cells binding support")
> Signed-off-by: Lin Yujun <linyujun809@huawei.com>
> ---

Reviewed-by: Stephen Boyd <sboyd@kernel.org>

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

* Re: [PATCH -next] clk: imx: scu: fix memleak on platform_device_add() fails
  2022-09-14  3:32 [PATCH -next] clk: imx: scu: fix memleak on platform_device_add() fails Lin Yujun
  2022-09-26  9:13 ` linyujun (C)
  2022-10-01  0:06 ` Stephen Boyd
@ 2022-10-01  0:07 ` Stephen Boyd
  2 siblings, 0 replies; 4+ messages in thread
From: Stephen Boyd @ 2022-10-01  0:07 UTC (permalink / raw)
  To: Lin Yujun, abelvesa, aisheng.dong, festevam, kernel, linux-imx,
	mturquette, s.hauer, shawnguo
  Cc: linux-clk, linux-arm-kernel, linux-kernel

Quoting Lin Yujun (2022-09-13 20:32:06)
> No error handling is performed when platform_device_add()
> fails. Add error processing before return, and modified
> the return value.
> 
> Fixes: 77d8f3068c63 ("clk: imx: scu: add two cells binding support")
> Signed-off-by: Lin Yujun <linyujun809@huawei.com>
> ---

Applied to clk-next

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

end of thread, other threads:[~2022-10-01  0:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-14  3:32 [PATCH -next] clk: imx: scu: fix memleak on platform_device_add() fails Lin Yujun
2022-09-26  9:13 ` linyujun (C)
2022-10-01  0:06 ` Stephen Boyd
2022-10-01  0:07 ` Stephen Boyd

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).