cpufreq: qcom-hw: Fix memory leak in qcom_cpufreq_hw_read_lut()

Message ID 20221108072302.736-1-judy.chenhui@huawei.com
State New
Headers
Series cpufreq: qcom-hw: Fix memory leak in qcom_cpufreq_hw_read_lut() |

Commit Message

Chen Hui Nov. 8, 2022, 7:23 a.m. UTC
  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>
---
 drivers/cpufreq/qcom-cpufreq-hw.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Sibi Sankar Nov. 8, 2022, 9:31 a.m. UTC | #1
Hey Chen,

Thanks for the patch.

On 11/8/22 12:53, Chen Hui wrote:
> 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")

Reviewed-by: Sibi Sankar <quic_sibis@quicinc.com>

> Signed-off-by: Chen Hui <judy.chenhui@huawei.com>
> ---
>   drivers/cpufreq/qcom-cpufreq-hw.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c
> index 833589bc95e4..d15097549e8c 100644
> --- a/drivers/cpufreq/qcom-cpufreq-hw.c
> +++ b/drivers/cpufreq/qcom-cpufreq-hw.c
> @@ -193,6 +193,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;
  
Viresh Kumar Nov. 9, 2022, 6:50 a.m. UTC | #2
On 08-11-22, 15:23, Chen Hui wrote:
> 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>
> ---
>  drivers/cpufreq/qcom-cpufreq-hw.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c
> index 833589bc95e4..d15097549e8c 100644
> --- a/drivers/cpufreq/qcom-cpufreq-hw.c
> +++ b/drivers/cpufreq/qcom-cpufreq-hw.c
> @@ -193,6 +193,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;

Applied. Thanks.
  

Patch

diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c
index 833589bc95e4..d15097549e8c 100644
--- a/drivers/cpufreq/qcom-cpufreq-hw.c
+++ b/drivers/cpufreq/qcom-cpufreq-hw.c
@@ -193,6 +193,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;