diff mbox series

[v3,3/5] PM / devfreq: Fix kernel panic with cpu based scaling to passive gov

Message ID 20220614110701.31240-4-ansuelsmth@gmail.com (mailing list archive)
State Superseded, archived
Delegated to: Chanwoo Choi
Headers show
Series PM / devfreq: Various Fixes to cpufreq based passive governor | expand

Commit Message

Christian Marangi June 14, 2022, 11:06 a.m. UTC
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: a03dacb0316f ("PM / devfreq: Add cpu based scaling support to passive governor")
Signed-off-by: Christian 'Ansuel' Marangi <ansuelsmth@gmail.com>
---
 drivers/devfreq/governor_passive.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Chanwoo Choi June 14, 2022, 11:06 p.m. UTC | #1
On 22. 6. 14. 20:06, Christian 'Ansuel' Marangi wrote:
> 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: a03dacb0316f ("PM / devfreq: Add cpu based scaling support to passive governor")
> Signed-off-by: Christian 'Ansuel' Marangi <ansuelsmth@gmail.com>
> ---
>  drivers/devfreq/governor_passive.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/devfreq/governor_passive.c b/drivers/devfreq/governor_passive.c
> index 3c3322adea03..be8aa6830413 100644
> --- a/drivers/devfreq/governor_passive.c
> +++ b/drivers/devfreq/governor_passive.c
> @@ -395,8 +395,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:

Applied it to devfreq-fixes. Thanks.
diff mbox series

Patch

diff --git a/drivers/devfreq/governor_passive.c b/drivers/devfreq/governor_passive.c
index 3c3322adea03..be8aa6830413 100644
--- a/drivers/devfreq/governor_passive.c
+++ b/drivers/devfreq/governor_passive.c
@@ -395,8 +395,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: