cpufreq/cpufreq_governor: Fix memory leak in cpufreq_dbs_governor_init
PATCH 1/1 cpufreq/cpufreq_governor: Fix memory leak in cpufreq_dbs_governor_init
In the implementation of cpufreq_dbs_governor_init(), dbs_data is allocated and later is assigned to governor_data. But before that assignment, if gov->init() fails this allocation is not released. dbs_data should be released in case if gov->init() failure.
--- drivers/cpufreq/cpufreq_governor.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/cpufreq/cpufreq_governor.c +3 -1
@@ -428,8 +428,10 @@ int cpufreq_dbs_governor_init(struct cpufreq_policy *policy)gov_attr_set_init (&dbs_data->attr_set, &policy_dbs->list); ret = gov->init (dbs_data); -if (ret) +if (ret) { +kfree (dbs_data); goto free_policy_dbs_info; + }/* * The sampling interval should not be less than the transition latency
Signature · 1 line
2.17.1
Viresh Kumar
maintainerQuoted 16 lines · Navid Emamdoost
In the implementation of
cpufreq_dbs_governor_init(),dbs_datais allocated and later is assigned togovernor_data. But before that assignment, ifgov->init()fails this allocation is not released.dbs_datashould be released in case ifgov->init()failure.Fixes 714a2d9c8792 ("cpufreq: governor: split cpufreq_governor_dbs()")Signed-off-by Navid Emamdoost <[email protected]>--- drivers/cpufreq/cpufreq_governor.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/cpufreq/cpufreq_governor.c +0
-0
drivers/cpufreq/cpufreq_governor.c int cpufreq_dbs_governor_init(struct cpufreq_policy *policy) · line 433
Quoted 7 lines
drivers/cpufreq/cpufreq_governor.c +2
-1@@ -428,8 +428,10 @@ int cpufreq_dbs_governor_init(struct cpufreq_policy *policy)gov_attr_set_init (&dbs_data->attr_set, &policy_dbs->list); ret = gov->init (dbs_data); -if (ret) +if (ret) { +kfree (dbs_data); goto free_policy_dbs_info;
Maybe add another label right before kfree() at the bottom and jump there instead. We wanted to share code in the error path.
Quoted 6 lines
drivers/cpufreq/cpufreq_governor.c +1
-0+ }/* * The sampling interval should not be less than the transition latency Signature · 1 line
2.17.1
Signature · 1 line
viresh