Skip to content

Commit

Permalink
clk: imx: scu: fix memleak on platform_device_add() fails
Browse files Browse the repository at this point in the history
[ Upstream commit 855ae87 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Lin Yujun authored and gregkh committed Oct 21, 2022
1 parent 86bef3f commit 05fe0b3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/clk/imx/clk-scu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 05fe0b3

Please sign in to comment.