[PATCH 2/2] x86/apic: Replace deprecated simple_strtol() with kstrtouint() in HPET check

From: Habil Eren Türker

Date: Sun Oct 04 2026 - 10:57:17 EST


The simple_strtol() function is deprecated because it explicitly ignores
overflows. Replace it with the proper variant, kstrtouint(),
in x86_fwspec_is_hpet(). Also add early returns.

It was detected while running a static analysis on the use of
simple_strtol() in the kernel.

Signed-off-by: Habil Eren Türker <habilerenturker@xxxxxxxxxxx>
---
arch/x86/kernel/apic/vector.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
index 2b46ff7c9..c83226ba5 100644
--- a/arch/x86/kernel/apic/vector.c
+++ b/arch/x86/kernel/apic/vector.c
@@ -687,14 +687,23 @@ int x86_fwspec_is_ioapic(struct irq_fwspec *fwspec)

int x86_fwspec_is_hpet(struct irq_fwspec *fwspec)
{
+ const char *fwname;
+ unsigned int val;
+
if (fwspec->param_count != 1)
return 0;

- if (is_fwnode_irqchip(fwspec->fwnode)) {
- const char *fwname = fwnode_get_name(fwspec->fwnode);
- return fwname && !strncmp(fwname, "HPET-MSI-", 9) &&
- simple_strtol(fwname+9, NULL, 10) == fwspec->param[0];
+ if (!is_fwnode_irqchip(fwspec->fwnode))
+ return 0;
+
+ fwname = fwnode_get_name(fwspec->fwnode);
+
+ if (fwname && !strncmp(fwname, "HPET-MSI-", 9) &&
+ kstrtouint(fwname + 9, 10, &val) == 0 &&
+ val == fwspec->param[0]) {
+ return 1;
}
+
return 0;
}

--
2.47.3