Skip to content

Commit

Permalink
PM / devfreq: Fix kernel panic with cpu based scaling to passive gov
Browse files Browse the repository at this point in the history
The cpufreq passive register notifier can PROBE_DEFER and the devfreq
struct is freed and then reallocaed on probe retry.
The current logic assume that the code can't PROBE_DEFER so the devfreq
struct in the this variable in devfreq_passive_data is assumed to be
(if already set) always correct.
This cause kernel panic as the code try to access the wrong address.
To correctly handle this, update the this variable in
devfreq_passive_data to the devfreq reallocated struct.

Fixes: a03dacb ("PM / devfreq: Add cpu based scaling support to passive governor")
Signed-off-by: Christian 'Ansuel' Marangi <[email protected]>
Signed-off-by: Chanwoo Choi <[email protected]>
  • Loading branch information
Ansuel authored and chanwoochoi committed Jun 29, 2022
1 parent 03c765b commit 57e00b4
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/devfreq/governor_passive.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,7 @@ static int devfreq_passive_event_handler(struct devfreq *devfreq,
if (!p_data)
return -EINVAL;

if (!p_data->this)
p_data->this = devfreq;
p_data->this = devfreq;

switch (event) {
case DEVFREQ_GOV_START:
Expand Down

0 comments on commit 57e00b4

Please sign in to comment.