]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
cpufreq: governor: Free dbs_data directly when gov->init() fails
authorLiao Chang <liaochang1@huawei.com>
Wed, 8 Apr 2026 12:47:46 +0000 (08:47 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 11 Apr 2026 12:16:36 +0000 (14:16 +0200)
[ Upstream commit 916f13884042f615cfbfc0b42cc68dadee826f2a ]

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>
Stable-dep-of: 6dcf9d0064ce ("cpufreq: governor: fix double free in cpufreq_dbs_governor_init() error path")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/cpufreq/cpufreq_governor.c

index f3475eb6d8a96cd5eff2c3113d75f22f7e5047f4..8f5474612b3124e023a09b1cf5b1c868351dba95 100644 (file)
@@ -440,7 +440,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
@@ -475,6 +475,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: