PCI/MSI: Fix msi_desc->affinity memory leak when freeing MSI IRQs.
PATCH 1/1 PCI/MSI: Fix msi_desc->affinity memory leak when freeing MSI IRQs.
No response ... trying again.
P.
---8<---
During device setup, msix_setup_entries() and msi_setup_entry() allocate msi_desc by calling alloc_msi_entry(). alloc_msi_entry() can also allocate a affinity cpumask. During device teardown free_msi_irqs() is called and the msi_desc is freed, but the affinity cpumask is leaked.
Fix it by calling free_msi_entry() which frees both the msi_desc and the affinity cpumask.
--- drivers/pci/msi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/msi.c +1 -1
@@ -379,7 +379,7 @@ static void free_msi_irqs(struct pci_dev *dev) }list_del (&entry->list); -kfree (entry); +free_msi_entry (entry); }if (dev->msi_irq_groups) {
Signature · 1 line
1.7.9.3
Quoted 6 lines · Prarit Bhargava
No response ... trying again.
P.
---8<---
Quoted 7 lines
During device setup,
msix_setup_entries()andmsi_setup_entry()allocatemsi_descby callingalloc_msi_entry().alloc_msi_entry()can also allocate a affinity cpumask. During device teardownfree_msi_irqs()is called and themsi_descis freed, but the affinity cpumask is leaked.Fix it by calling
free_msi_entry()which frees both themsi_descand the affinity cpumask.
Sorry for the delay, Prarit. I started looking at this when you first posted it. The more I looked at it, the less I liked the setup/free paths -- they're not very parallel and I don't remember what else.
But I guess it's probably a longer term effort to clean that up.
Do you have a bug report or anything for this, or did you just find this by code inspection? If there's a bugzilla or even a symptom, we could mention it in the changelog.
Quoted 23 lines
Signed-off-by Prarit Bhargava <[email protected]>Cc Bjorn Helgaas <[email protected]>--- drivers/pci/msi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/msi.c +1
-1@@ -379,7 +379,7 @@ static void free_msi_irqs(struct pci_dev *dev) }list_del (&entry->list); -kfree (entry); +free_msi_entry (entry); }if (dev->msi_irq_groups) {Signature · 1 line
1.7.9.3
Quoted 12 lines · Bjorn Helgaas
Quoted 11 lines · Prarit Bhargava
No response ... trying again.
P.
---8<---
During device setup,
msix_setup_entries()andmsi_setup_entry()allocatemsi_descby callingalloc_msi_entry().alloc_msi_entry()can also allocate a affinity cpumask. During device teardownfree_msi_irqs()is called and themsi_descis freed, but the affinity cpumask is leaked.
Quoted 7 lines
Quoted 2 lines
Fix it by calling
free_msi_entry()which frees both themsi_descand the affinity cpumask.Sorry for the delay, Prarit. I started looking at this when you first posted it. The more I looked at it, the less I liked the setup/free paths -- they're not very parallel and I don't remember what else.
Yes, I noticed this as well. As you say ...
Quoted 2 lines
But I guess it's probably a longer term effort to clean that up.
... there's a larger cleanup that's required here.
Quoted 4 lines
Do you have a bug report or anything for this, or did you just find this by code inspection? If there's a bugzilla or even a symptom, we could mention it in the changelog.
This was noticed during code inspection while Myron & I were debugging an issue in RHEL7.
P.
Quoted 23 lines
Quoted 23 lines
Signed-off-by Prarit Bhargava <[email protected]>Cc Bjorn Helgaas <[email protected]>--- drivers/pci/msi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/msi.c +1
-1@@ -379,7 +379,7 @@ static void free_msi_irqs(struct pci_dev *dev) }list_del (&entry->list); -kfree (entry); +free_msi_entry (entry); }if (dev->msi_irq_groups) {Signature · 1 line
1.7.9.3
Bjorn Helgaas
AppliedQuoted 11 lines · Prarit Bhargava
No response ... trying again.
P.
---8<---
During device setup,
msix_setup_entries()andmsi_setup_entry()allocatemsi_descby callingalloc_msi_entry().alloc_msi_entry()can also allocate a affinity cpumask. During device teardownfree_msi_irqs()is called and themsi_descis freed, but the affinity cpumask is leaked.
Quoted 6 lines
Fix it by calling
free_msi_entry()which frees both themsi_descand the affinity cpumask.Signed-off-by Prarit Bhargava <[email protected]>Cc Bjorn Helgaas <[email protected]>
Applied to pci/msi for v4.11, thanks, Prarit!
Quoted 20 lines
--- drivers/pci/msi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/msi.c +1
-1@@ -379,7 +379,7 @@ static void free_msi_irqs(struct pci_dev *dev) }list_del (&entry->list); -kfree (entry); +free_msi_entry (entry); }if (dev->msi_irq_groups) {Signature · 1 line
1.7.9.3