summaryrefslogtreecommitdiff
path: root/drivers/clk/imx
diff options
context:
space:
mode:
authorLin Yujun <linyujun809@huawei.com>2022-09-14 06:32:06 +0300
committerStephen Boyd <sboyd@kernel.org>2022-10-01 03:06:59 +0300
commit855ae87a2073ebf1b395e020de54fdf9ce7d166f (patch)
treed68eb4343dbd45357752276525e1abdb3796cd1f /drivers/clk/imx
parent0049eb1a44ce98bd0c8d3a2d9fec150664da8d66 (diff)
downloadlinux-855ae87a2073ebf1b395e020de54fdf9ce7d166f.tar.xz
clk: imx: scu: fix memleak on platform_device_add() fails
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> Link: https://lore.kernel.org/r/20220914033206.98046-1-linyujun809@huawei.com Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Diffstat (limited to 'drivers/clk/imx')
-rw-r--r--drivers/clk/imx/clk-scu.c6
1 files changed, 5 insertions, 1 deletions
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;