cpufreq: qcom-hw: Fix memory leak in qcom_cpufreq_hw_read_lut()
authorChen Hui <judy.chenhui@huawei.com>
Tue, 8 Nov 2022 07:23:02 +0000 (15:23 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:14:01 +0000 (13:14 +0100)
[ Upstream commit 9901c21bcaf2f01fe5078f750d624f4ddfa8f81b ]

If "cpu_dev" fails to get opp table in qcom_cpufreq_hw_read_lut(),
the program will return, resulting in "table" resource is not released.

Fixes: 51c843cf77bb ("cpufreq: qcom: Update the bandwidth levels on frequency change")
Signed-off-by: Chen Hui <judy.chenhui@huawei.com>
Reviewed-by: Sibi Sankar <quic_sibis@quicinc.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/cpufreq/qcom-cpufreq-hw.c

index bb2f59f..bbcba2c 100644 (file)
@@ -177,6 +177,7 @@ static int qcom_cpufreq_hw_read_lut(struct device *cpu_dev,
                }
        } else if (ret != -ENODEV) {
                dev_err(cpu_dev, "Invalid opp table in device tree\n");
+               kfree(table);
                return ret;
        } else {
                policy->fast_switch_possible = true;