Skip to content

Commit 855ae87

Browse files
Lin Yujunbebarino
authored andcommitted
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: 77d8f30 ("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>
1 parent 0049eb1 commit 855ae87

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/clk/imx/clk-scu.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,11 @@ struct clk_hw *imx_clk_scu_alloc_dev(const char *name,
695695
pr_warn("%s: failed to attached the power domain %d\n",
696696
name, ret);
697697

698-
platform_device_add(pdev);
698+
ret = platform_device_add(pdev);
699+
if (ret) {
700+
platform_device_put(pdev);
701+
return ERR_PTR(ret);
702+
}
699703

700704
/* For API backwards compatiblilty, simply return NULL for success */
701705
return NULL;

0 commit comments

Comments
 (0)