mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* PCI: vmd: repeated kfree of vmdirq
@ 2025-07-17 11:48 Colin King (gmail)
  2025-07-17 11:52 ` Nam Cao
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King (gmail) @ 2025-07-17 11:48 UTC (permalink / raw)
  To: Nam Cao, Manivannan Sadhasivam, Thomas Gleixner, Bjorn Helgaas
  Cc: Lorenzo Pieralisi, Krzysztof Wilczyński,
	Manivannan Sadhasivam, linux-pci, linux-kernel


[-- Attachment #1.1.1: Type: text/plain, Size: 868 bytes --]

Hi,

Static analysis found an issue in the following commit in linux-next:

commit 2b96beffa42760513567919aa27eb72035f2db58
Author: Nam Cao <namcao@linutronix.de>
Date:   Thu Jun 26 16:48:06 2025 +0200

     PCI: vmd: Switch to msi_create_parent_irq_domain()


The issue is as follows:

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);

         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--;

                 kfree(vmdirq);
         }
}

The for-loop is repeatedly kfree'ing vmdirq which seems incorrect.

Colin

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 4901 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: PCI: vmd: repeated kfree of vmdirq
  2025-07-17 11:48 PCI: vmd: repeated kfree of vmdirq Colin King (gmail)
@ 2025-07-17 11:52 ` Nam Cao
  0 siblings, 0 replies; 2+ messages in thread
From: Nam Cao @ 2025-07-17 11:52 UTC (permalink / raw)
  To: Colin King (gmail)
  Cc: Manivannan Sadhasivam, Thomas Gleixner, Bjorn Helgaas,
	Lorenzo Pieralisi, Krzysztof Wilczyński, linux-pci,
	linux-kernel

On Thu, Jul 17, 2025 at 12:48:02PM +0100, Colin King (gmail) wrote:
> Hi,
> 
> Static analysis found an issue in the following commit in linux-next:
> 
> commit 2b96beffa42760513567919aa27eb72035f2db58
> Author: Nam Cao <namcao@linutronix.de>
> Date:   Thu Jun 26 16:48:06 2025 +0200
> 
>     PCI: vmd: Switch to msi_create_parent_irq_domain()
> 
> 
> The issue is as follows:
> 
> 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);
> 
>         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--;
> 
>                 kfree(vmdirq);
>         }
> }
> 
> The for-loop is repeatedly kfree'ing vmdirq which seems incorrect.

Thanks for the report. It has been resolved in PCI tree.

Best regards,
Nam

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-07-17 11:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-17 11:48 PCI: vmd: repeated kfree of vmdirq Colin King (gmail)
2025-07-17 11:52 ` Nam Cao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®