cpufreq: governor: Free dbs_data directly when gov->init() fails
authorLiao Chang <liaochang1@huawei.com>
Tue, 29 Aug 2023 07:03:46 +0000 (07:03 +0000)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 29 Aug 2023 18:21:35 +0000 (20:21 +0200)
Due to the kobject embedded in the dbs_data doest not has a release()
method yet, it needs to use kfree() to free dbs_data directly when
governor fails to allocate the tunner field of dbs_data.

Signed-off-by: Liao Chang <liaochang1@huawei.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/cpufreq_governor.c

index 85da677c43d6bde7077a80e1562b6b4b9a7faf8f..af44ee6a64304f0e56265b9bbf5c00a60285726d 100644 (file)
@@ -439,7 +439,7 @@ int cpufreq_dbs_governor_init(struct cpufreq_policy *policy)
 
        ret = gov->init(dbs_data);
        if (ret)
-               goto free_policy_dbs_info;
+               goto free_dbs_data;
 
        /*
         * The sampling interval should not be less than the transition latency
@@ -474,6 +474,8 @@ int cpufreq_dbs_governor_init(struct cpufreq_policy *policy)
        if (!have_governor_per_policy())
                gov->gdbs_data = NULL;
        gov->exit(dbs_data);
+
+free_dbs_data:
        kfree(dbs_data);
 
 free_policy_dbs_info: