* [PATCH v3] cpufreq: cppc: Set fie_disabled to FIE_DISABLED if fails to create kworker_fie
@ 2023-08-17 7:47 Liao Chang
2023-08-17 8:43 ` Viresh Kumar
2023-08-17 8:56 ` Viresh Kumar
0 siblings, 2 replies; 6+ messages in thread
From: Liao Chang @ 2023-08-17 7:47 UTC (permalink / raw)
To: rafael, viresh.kumar; +Cc: linux-pm, linux-kernel
The function cppc_freq_invariance_init() may failed to create
kworker_fie, make it more robust by setting fie_disabled to FIE_DISBALED
to prevent an invalid pointer dereference in kthread_destroy_worker(),
which called from cppc_freq_invariance_exit().
v3:
Simplify cleanup code when invariance initialization fails.
v2:
Set fie_disabled to FIE_DISABLED when invariance initialization fails.
Link: https://lore.kernel.org/all/20230816034630.a4hvsj373q6aslk3@vireshk-i7/
Signed-off-by: Liao Chang <liaochang1@huawei.com>
---
drivers/cpufreq/cppc_cpufreq.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
index 022e3555407c..4d501f0bf55d 100644
--- a/drivers/cpufreq/cppc_cpufreq.c
+++ b/drivers/cpufreq/cppc_cpufreq.c
@@ -249,15 +249,19 @@ static void __init cppc_freq_invariance_init(void)
return;
kworker_fie = kthread_create_worker(0, "cppc_fie");
- if (IS_ERR(kworker_fie))
+ if (IS_ERR(kworker_fie)) {
+ pr_warn("%s: failed to create kworker_fie: %ld\n", __func__,
+ PTR_ERR(kworker_fie));
+ fie_disabled = FIE_DISABLED;
return;
+ }
ret = sched_setattr_nocheck(kworker_fie->task, &attr);
if (ret) {
pr_warn("%s: failed to set SCHED_DEADLINE: %d\n", __func__,
ret);
kthread_destroy_worker(kworker_fie);
- return;
+ fie_disabled = FIE_DISABLED;
}
}
@@ -267,7 +271,6 @@ static void cppc_freq_invariance_exit(void)
return;
kthread_destroy_worker(kworker_fie);
- kworker_fie = NULL;
}
#else
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH v3] cpufreq: cppc: Set fie_disabled to FIE_DISABLED if fails to create kworker_fie
2023-08-17 7:47 [PATCH v3] cpufreq: cppc: Set fie_disabled to FIE_DISABLED if fails to create kworker_fie Liao Chang
@ 2023-08-17 8:43 ` Viresh Kumar
2023-08-17 8:56 ` Viresh Kumar
1 sibling, 0 replies; 6+ messages in thread
From: Viresh Kumar @ 2023-08-17 8:43 UTC (permalink / raw)
To: Liao Chang; +Cc: rafael, linux-pm, linux-kernel
On 17-08-23, 07:47, Liao Chang wrote:
> The function cppc_freq_invariance_init() may failed to create
> kworker_fie, make it more robust by setting fie_disabled to FIE_DISBALED
> to prevent an invalid pointer dereference in kthread_destroy_worker(),
> which called from cppc_freq_invariance_exit().
>
> v3:
> Simplify cleanup code when invariance initialization fails.
>
> v2:
> Set fie_disabled to FIE_DISABLED when invariance initialization fails.
>
> Link: https://lore.kernel.org/all/20230816034630.a4hvsj373q6aslk3@vireshk-i7/
>
> Signed-off-by: Liao Chang <liaochang1@huawei.com>
> ---
> drivers/cpufreq/cppc_cpufreq.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
> index 022e3555407c..4d501f0bf55d 100644
> --- a/drivers/cpufreq/cppc_cpufreq.c
> +++ b/drivers/cpufreq/cppc_cpufreq.c
> @@ -249,15 +249,19 @@ static void __init cppc_freq_invariance_init(void)
> return;
>
> kworker_fie = kthread_create_worker(0, "cppc_fie");
> - if (IS_ERR(kworker_fie))
> + if (IS_ERR(kworker_fie)) {
> + pr_warn("%s: failed to create kworker_fie: %ld\n", __func__,
> + PTR_ERR(kworker_fie));
> + fie_disabled = FIE_DISABLED;
> return;
> + }
>
> ret = sched_setattr_nocheck(kworker_fie->task, &attr);
> if (ret) {
> pr_warn("%s: failed to set SCHED_DEADLINE: %d\n", __func__,
> ret);
> kthread_destroy_worker(kworker_fie);
> - return;
> + fie_disabled = FIE_DISABLED;
> }
> }
>
> @@ -267,7 +271,6 @@ static void cppc_freq_invariance_exit(void)
> return;
>
> kthread_destroy_worker(kworker_fie);
> - kworker_fie = NULL;
> }
>
> #else
Applied. Thanks.
--
viresh
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v3] cpufreq: cppc: Set fie_disabled to FIE_DISABLED if fails to create kworker_fie
2023-08-17 7:47 [PATCH v3] cpufreq: cppc: Set fie_disabled to FIE_DISABLED if fails to create kworker_fie Liao Chang
2023-08-17 8:43 ` Viresh Kumar
@ 2023-08-17 8:56 ` Viresh Kumar
2023-08-17 10:44 ` Liao, Chang
1 sibling, 1 reply; 6+ messages in thread
From: Viresh Kumar @ 2023-08-17 8:56 UTC (permalink / raw)
To: Liao Chang; +Cc: rafael, linux-pm, linux-kernel
On 17-08-23, 07:47, Liao Chang wrote:
> The function cppc_freq_invariance_init() may failed to create
> kworker_fie, make it more robust by setting fie_disabled to FIE_DISBALED
> to prevent an invalid pointer dereference in kthread_destroy_worker(),
> which called from cppc_freq_invariance_exit().
Btw, this version information present below should be added ... (see later)
> v3:
> Simplify cleanup code when invariance initialization fails.
>
> v2:
> Set fie_disabled to FIE_DISABLED when invariance initialization fails.
>
> Link: https://lore.kernel.org/all/20230816034630.a4hvsj373q6aslk3@vireshk-i7/
>
> Signed-off-by: Liao Chang <liaochang1@huawei.com>
> ---
... here after the "---" line, this way this not-so-useful information will not
be committed while applying the patch.
> drivers/cpufreq/cppc_cpufreq.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
--
viresh
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] cpufreq: cppc: Set fie_disabled to FIE_DISABLED if fails to create kworker_fie
2023-08-17 8:56 ` Viresh Kumar
@ 2023-08-17 10:44 ` Liao, Chang
2023-08-17 10:48 ` Viresh Kumar
0 siblings, 1 reply; 6+ messages in thread
From: Liao, Chang @ 2023-08-17 10:44 UTC (permalink / raw)
To: Viresh Kumar; +Cc: rafael, linux-pm, linux-kernel
Hi Viresh,
在 2023/8/17 16:56, Viresh Kumar 写道:
> On 17-08-23, 07:47, Liao Chang wrote:
>> The function cppc_freq_invariance_init() may failed to create
>> kworker_fie, make it more robust by setting fie_disabled to FIE_DISBALED
>> to prevent an invalid pointer dereference in kthread_destroy_worker(),
>> which called from cppc_freq_invariance_exit().
>
> Btw, this version information present below should be added ... (see later)
>
>> v3:
>> Simplify cleanup code when invariance initialization fails.
>>
>> v2:
>> Set fie_disabled to FIE_DISABLED when invariance initialization fails.
>>
>> Link: https://lore.kernel.org/all/20230816034630.a4hvsj373q6aslk3@vireshk-i7/
>>
>> Signed-off-by: Liao Chang <liaochang1@huawei.com>
>> ---
>
> ... here after the "---" line, this way this not-so-useful information will not
> be committed while applying the patch.
Got it, I will move the "v2:... v3:..." lines below the "---" line in next patch.
Thanks.
>
>> drivers/cpufreq/cppc_cpufreq.c | 9 ++++++---
>> 1 file changed, 6 insertions(+), 3 deletions(-)
--
BR
Liao, Chang
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] cpufreq: cppc: Set fie_disabled to FIE_DISABLED if fails to create kworker_fie
2023-08-17 10:44 ` Liao, Chang
@ 2023-08-17 10:48 ` Viresh Kumar
2023-08-18 1:09 ` Liao, Chang
0 siblings, 1 reply; 6+ messages in thread
From: Viresh Kumar @ 2023-08-17 10:48 UTC (permalink / raw)
To: Liao, Chang; +Cc: rafael, linux-pm, linux-kernel
On 17-08-23, 18:44, Liao, Chang wrote:
> Hi Viresh,
>
> 在 2023/8/17 16:56, Viresh Kumar 写道:
> > On 17-08-23, 07:47, Liao Chang wrote:
> >> The function cppc_freq_invariance_init() may failed to create
> >> kworker_fie, make it more robust by setting fie_disabled to FIE_DISBALED
> >> to prevent an invalid pointer dereference in kthread_destroy_worker(),
> >> which called from cppc_freq_invariance_exit().
> >
> > Btw, this version information present below should be added ... (see later)
> >
> >> v3:
> >> Simplify cleanup code when invariance initialization fails.
> >>
> >> v2:
> >> Set fie_disabled to FIE_DISABLED when invariance initialization fails.
> >>
> >> Link: https://lore.kernel.org/all/20230816034630.a4hvsj373q6aslk3@vireshk-i7/
> >>
> >> Signed-off-by: Liao Chang <liaochang1@huawei.com>
> >> ---
> >
> > ... here after the "---" line, this way this not-so-useful information will not
> > be committed while applying the patch.
>
> Got it, I will move the "v2:... v3:..." lines below the "---" line in next patch.
I have already applied the fixed version now, don't resend it :)
--
viresh
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] cpufreq: cppc: Set fie_disabled to FIE_DISABLED if fails to create kworker_fie
2023-08-17 10:48 ` Viresh Kumar
@ 2023-08-18 1:09 ` Liao, Chang
0 siblings, 0 replies; 6+ messages in thread
From: Liao, Chang @ 2023-08-18 1:09 UTC (permalink / raw)
To: Viresh Kumar; +Cc: rafael, linux-pm, linux-kernel
在 2023/8/17 18:48, Viresh Kumar 写道:
> On 17-08-23, 18:44, Liao, Chang wrote:
>> Hi Viresh,
>>
>> 在 2023/8/17 16:56, Viresh Kumar 写道:
>>> On 17-08-23, 07:47, Liao Chang wrote:
>>>> The function cppc_freq_invariance_init() may failed to create
>>>> kworker_fie, make it more robust by setting fie_disabled to FIE_DISBALED
>>>> to prevent an invalid pointer dereference in kthread_destroy_worker(),
>>>> which called from cppc_freq_invariance_exit().
>>>
>>> Btw, this version information present below should be added ... (see later)
>>>
>>>> v3:
>>>> Simplify cleanup code when invariance initialization fails.
>>>>
>>>> v2:
>>>> Set fie_disabled to FIE_DISABLED when invariance initialization fails.
>>>>
>>>> Link: https://lore.kernel.org/all/20230816034630.a4hvsj373q6aslk3@vireshk-i7/
>>>>
>>>> Signed-off-by: Liao Chang <liaochang1@huawei.com>
>>>> ---
>>>
>>> ... here after the "---" line, this way this not-so-useful information will not
>>> be committed while applying the patch.
>>
>> Got it, I will move the "v2:... v3:..." lines below the "---" line in next patch.
>
> I have already applied the fixed version now, don't resend it :)
OK,thanks
>
--
BR
Liao, Chang
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-08-18 1:10 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-17 7:47 [PATCH v3] cpufreq: cppc: Set fie_disabled to FIE_DISABLED if fails to create kworker_fie Liao Chang
2023-08-17 8:43 ` Viresh Kumar
2023-08-17 8:56 ` Viresh Kumar
2023-08-17 10:44 ` Liao, Chang
2023-08-17 10:48 ` Viresh Kumar
2023-08-18 1:09 ` Liao, Chang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox