Re: [PATCH] cpufreq: Allocate QoS freq_req objects with policy

From: Pierre Gondois

Date: Tue Mar 31 2026 - 03:07:14 EST



On 3/31/26 08:44, zhenglifeng (A) wrote:
On 3/31/2026 1:03 PM, Viresh Kumar wrote:
A recent change exposed a bug in the error path: if
freq_qos_add_request(boost_freq_req) fails, min_freq_req may remain a
valid pointer even though it was never successfully added. During policy
teardown, this leads to an unconditional call to
freq_qos_remove_request(), triggering a WARN.

The current design allocates all three freq_req objects together, making
the lifetime rules unclear and error handling fragile.

Simplify this by allocating the QoS freq_req objects at policy
allocation time. The policy itself is dynamically allocated, and two of
the three requests are always needed anyway. This ensures consistent
lifetime management and eliminates the inconsistent state in failure
paths.

Reported-by: Zhongqiu Han <zhongqiu.han@xxxxxxxxxxxxxxxx>
Fixes: 6e39ba4e5a82 ("cpufreq: Add boost_freq_req QoS request")
Signed-off-by: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
This looks much neater. Thanks!

Reviewed-by: Lifeng Zheng <zhenglifeng1@xxxxxxxxxx>
Thanks for fixing the patch, removing the allocation makes

things much cleaner.

Tested-by: Pierre Gondois <pierre.gondois@xxxxxxx>