[PATCH v2 1/2] x86/apic: Replace deprecated simple_strtol() with sscanf() for robust parsing

From: Habil Eren Türker

Date: Mon Oct 05 2026 - 12:35:37 EST


The simple_strtol() function is deprecated because it explicitly ignores
overflows. Replace it with sscanf() for proper check
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 | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
index bddc54465..1a30b47c5 100644
--- a/arch/x86/kernel/apic/vector.c
+++ b/arch/x86/kernel/apic/vector.c
@@ -663,14 +663,21 @@ 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 && sscanf(fwname, "IO-APIC-%u", &val) == 1 &&
+ 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