[PATCH 1/2] x86/apic: Replace deprecated simple_strtol() with kstrtouint()
From: Habil Eren Türker
Date: Sun Oct 04 2026 - 10:57:11 EST
The simple_strtol() function is deprecated because it explicitly ignores
overflows. Replace it with the proper variant, kstrtouint(),
in x86_fwspec_is_ioapic.
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 | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
index bddc54465..2b46ff7c9 100644
--- a/arch/x86/kernel/apic/vector.c
+++ b/arch/x86/kernel/apic/vector.c
@@ -663,14 +663,23 @@ static void x86_vector_debug_show(struct seq_file *m, struct irq_domain *d,
int x86_fwspec_is_ioapic(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, "IO-APIC-", 8) &&
- simple_strtol(fwname+8, NULL, 10) == fwspec->param[0];
+ fwname = fwnode_get_name(fwspec->fwnode);
+
+ if (fwname && !strncmp(fwname, "IO-APIC-", 8) &&
+ kstrtouint(fwname + 8, 10, &val) == 0 &&
+ val == fwspec->param[0]) {
+ return 1;
+ }
+ return 0;
}
+
return to_of_node(fwspec->fwnode) &&
of_device_is_compatible(to_of_node(fwspec->fwnode),
"intel,ce4100-ioapic");
--
2.47.3