* [PATCH v1] PM: QoS: Fix misc device registration unwind
@ 2026-06-08 17:07 Yuho Choi
2026-06-09 16:13 ` Rafael J. Wysocki
0 siblings, 1 reply; 2+ messages in thread
From: Yuho Choi @ 2026-06-08 17:07 UTC (permalink / raw)
To: Rafael J . Wysocki, Len Brown, Pavel Machek
Cc: linux-pm, linux-kernel, Yuho Choi
cpu_latency_qos_init() registers cpu_dma_latency first and, when
CONFIG_PM_QOS_CPU_SYSTEM_WAKEUP is enabled, registers cpu_wakeup_latency
afterwards. The second registration overwrites the first return value.
As a result, a failure to register cpu_dma_latency can be masked if the
second registration succeeds. Conversely, if cpu_dma_latency succeeds and
cpu_wakeup_latency fails, the function returns an error while leaving the
first misc device registered.
Return immediately on the first registration failure and deregister
cpu_dma_latency if the second registration fails.
Fixes: a4e6512a79d8 ("PM: QoS: Introduce a CPU system wakeup QoS limit")
Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
---
kernel/power/qos.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/kernel/power/qos.c b/kernel/power/qos.c
index 398b994b73aa..1944dbeb0d4c 100644
--- a/kernel/power/qos.c
+++ b/kernel/power/qos.c
@@ -519,18 +519,23 @@ static int __init cpu_latency_qos_init(void)
int ret;
ret = misc_register(&cpu_latency_qos_miscdev);
- if (ret < 0)
+ if (ret < 0) {
pr_err("%s: %s setup failed\n", __func__,
cpu_latency_qos_miscdev.name);
+ return ret;
+ }
#ifdef CONFIG_PM_QOS_CPU_SYSTEM_WAKEUP
ret = misc_register(&cpu_wakeup_latency_qos_miscdev);
- if (ret < 0)
+ if (ret < 0) {
pr_err("%s: %s setup failed\n", __func__,
cpu_wakeup_latency_qos_miscdev.name);
+ misc_deregister(&cpu_latency_qos_miscdev);
+ return ret;
+ }
#endif
- return ret;
+ return 0;
}
late_initcall(cpu_latency_qos_init);
#endif /* CONFIG_CPU_IDLE */
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v1] PM: QoS: Fix misc device registration unwind
2026-06-08 17:07 [PATCH v1] PM: QoS: Fix misc device registration unwind Yuho Choi
@ 2026-06-09 16:13 ` Rafael J. Wysocki
0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2026-06-09 16:13 UTC (permalink / raw)
To: Yuho Choi
Cc: Rafael J . Wysocki, Len Brown, Pavel Machek, linux-pm,
linux-kernel
On Mon, Jun 8, 2026 at 7:08 PM Yuho Choi <dbgh9129@gmail.com> wrote:
>
> cpu_latency_qos_init() registers cpu_dma_latency first and, when
> CONFIG_PM_QOS_CPU_SYSTEM_WAKEUP is enabled, registers cpu_wakeup_latency
> afterwards. The second registration overwrites the first return value.
>
> As a result, a failure to register cpu_dma_latency can be masked if the
> second registration succeeds. Conversely, if cpu_dma_latency succeeds and
> cpu_wakeup_latency fails, the function returns an error while leaving the
> first misc device registered.
>
> Return immediately on the first registration failure and deregister
> cpu_dma_latency if the second registration fails.
>
> Fixes: a4e6512a79d8 ("PM: QoS: Introduce a CPU system wakeup QoS limit")
> Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
> ---
> kernel/power/qos.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/power/qos.c b/kernel/power/qos.c
> index 398b994b73aa..1944dbeb0d4c 100644
> --- a/kernel/power/qos.c
> +++ b/kernel/power/qos.c
> @@ -519,18 +519,23 @@ static int __init cpu_latency_qos_init(void)
> int ret;
>
> ret = misc_register(&cpu_latency_qos_miscdev);
> - if (ret < 0)
> + if (ret < 0) {
> pr_err("%s: %s setup failed\n", __func__,
> cpu_latency_qos_miscdev.name);
> + return ret;
> + }
>
> #ifdef CONFIG_PM_QOS_CPU_SYSTEM_WAKEUP
> ret = misc_register(&cpu_wakeup_latency_qos_miscdev);
> - if (ret < 0)
> + if (ret < 0) {
> pr_err("%s: %s setup failed\n", __func__,
> cpu_wakeup_latency_qos_miscdev.name);
> + misc_deregister(&cpu_latency_qos_miscdev);
> + return ret;
> + }
> #endif
>
> - return ret;
> + return 0;
> }
> late_initcall(cpu_latency_qos_init);
> #endif /* CONFIG_CPU_IDLE */
> --
Applied as 7.2 material, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-09 16:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-08 17:07 [PATCH v1] PM: QoS: Fix misc device registration unwind Yuho Choi
2026-06-09 16:13 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox