Re: [PATCH v5 5/7] genirq: Add GSIM user space configuration (procfs)

[email protected]
Newsgroups org.kernel.vger.linux-pci
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Unconditional removal of conditionally created `allow_sw_moderation` proc entry triggers `WARN(1)` on unsupported IRQs.
--

--- Patch [5]: [PATCH v5 5/7] genirq: Add GSIM user space configuration (procfs) ---
commit fc9564358ed0238056ccb83c0aee7d6d588c4901
Author: Luigi Rizzo <[email protected]>

genirq: Add GSIM user space configuration (procfs)

Introduce procfs interfaces to configure and monitor GSIM at runtime.
This adds a global directory /proc/irq/sw_moderation/ and per-IRQ files 
to individually allow or disallow moderation.

> diff --git a/kernel/irq/irq_moderation.c b/kernel/irq/irq_moderation.c
> index 2c75feb6634f3..1474d33455410 100644
> --- a/kernel/irq/irq_moderation.c
> +++ b/kernel/irq/irq_moderation.c
[ ... ]
> +void irq_moderation_procfs_add(struct irq_desc *desc, umode_t umode)
> +{
> +	if (!irq_moderation_supported(desc))
> +		return;
> +	proc_create_data("allow_sw_moderation", umode, desc->dir,
> +			 &allow_flag_ops, (void *)(long)desc->irq_data.irq);
> +}
> +
> +void irq_moderation_procfs_remove(struct irq_desc *desc)
> +{
> +	remove_proc_entry("allow_sw_moderation", desc->dir);

[Severity: Medium]
Will this unconditional call to remove_proc_entry() trigger a kernel warning
when unregistering an unsupported IRQ?

In irq_moderation_procfs_add() just above, the "allow_sw_moderation" procfs
entry is only created if irq_moderation_supported(desc) evaluates to true.

Because irq_moderation_procfs_remove() lacks the same check, freeing a dynamic
IRQ that doesn't support moderation will cause remove_proc_entry() to print a
warning stack trace about a missing entry.

Could we add the same !irq_moderation_supported(desc) check here to avoid
the warning?

> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.