Re: [PATCH 16/16] PCI: vmd: Switch to msi_create_parent_irq_domain()

Antonio Quartulli
2025-07-16T21:13:09Z

Hi Nam,

On 26/06/2025 16:48, Nam Cao wrote:
[...]
> -static void vmd_msi_free(struct irq_domain *domain,
> - struct msi_domain_info *info, unsigned int virq)
> +static void vmd_msi_free(struct irq_domain *domain, unsigned int virq, unsigned int nr_irqs)
> {
> struct vmd_irq *vmdirq = irq_get_chip_data(virq);
>
> - synchronize_srcu(&vmdirq->irq->srcu);
> + for (int i = 0; i < nr_irqs; ++i) {
> + synchronize_srcu(&vmdirq->irq->srcu);
>
> - /* XXX: Potential optimization to rebalance */
> - scoped_guard(raw_spinlock_irq, &list_lock)
> - vmdirq->irq->count--;
> + /* XXX: Potential optimization to rebalance */
> + scoped_guard(raw_spinlock_irq, &list_lock)
> + vmdirq->irq->count--;
>
> - kfree(vmdirq);
> + kfree(vmdirq);
> + }

By introducing a for loop in this function, you are re-using vmdirq
after free'ing it.

I can't send a patch because I am not faimliar with this API and I don't
know how to fix it.

However, the issue was reported today by Coverity.

Any idea? :-)

Regards,

--
Antonio Quartulli

CEO and Co-Founder
Mandelbit Srl