diff mbox series

[-next] cpufreq: qcom-hw: Fix memory leak in qcom_cpufreq_hw_driver_probe()

Message ID 20221122123514.172459-1-xiujianfeng@huawei.com
State New
Headers show
Series [-next] cpufreq: qcom-hw: Fix memory leak in qcom_cpufreq_hw_driver_probe() | expand

Commit Message

xiujianfeng Nov. 22, 2022, 12:35 p.m. UTC
If devm_clk_hw_register() fails, clk_init.name should be freed before
return error, otherwise will cause memory leak issue, fix it.

Fixes: 84063a1cbe9e ("cpufreq: qcom-hw: Add CPU clock provider support")
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
---
 drivers/cpufreq/qcom-cpufreq-hw.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c
index 1bd1e9ae5308..340fed35e45d 100644
--- a/drivers/cpufreq/qcom-cpufreq-hw.c
+++ b/drivers/cpufreq/qcom-cpufreq-hw.c
@@ -723,6 +723,7 @@  static int qcom_cpufreq_hw_driver_probe(struct platform_device *pdev)
 		ret = devm_clk_hw_register(dev, &data->cpu_clk);
 		if (ret < 0) {
 			dev_err(dev, "Failed to register clock %d: %d\n", i, ret);
+			kfree(clk_init.name);
 			return ret;
 		}