Commit 855ae87a authored by Lin Yujun's avatar Lin Yujun Committed by Stephen Boyd

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: 77d8f306 ("clk: imx: scu: add two cells binding support")
Signed-off-by: default avatarLin Yujun <linyujun809@huawei.com>
Link: https://lore.kernel.org/r/20220914033206.98046-1-linyujun809@huawei.comSigned-off-by: default avatarStephen Boyd <sboyd@kernel.org>
parent 0049eb1a
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment