linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESENT PATCH] PCI/MSI: Fix msi_desc->affinity memory leak when freeing MSI IRQs.
@ 2017-02-15 16:53 Prarit Bhargava
  2017-02-15 23:56 ` Bjorn Helgaas
  2017-02-17 21:47 ` Bjorn Helgaas
  0 siblings, 2 replies; 4+ messages in thread
From: Prarit Bhargava @ 2017-02-15 16:53 UTC (permalink / raw)
  To: linux-pci; +Cc: Prarit Bhargava, mstowe, Bjorn Helgaas

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.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Cc: mstowe@redhat.com
Cc: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/msi.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 50c5003295ca..3d709311052d 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -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) {
-- 
1.7.9.3

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

* Re: [RESENT PATCH] PCI/MSI: Fix msi_desc->affinity memory leak when freeing MSI IRQs.
  2017-02-15 16:53 [RESENT PATCH] PCI/MSI: Fix msi_desc->affinity memory leak when freeing MSI IRQs Prarit Bhargava
@ 2017-02-15 23:56 ` Bjorn Helgaas
  2017-02-16 12:47   ` Prarit Bhargava
  2017-02-17 21:47 ` Bjorn Helgaas
  1 sibling, 1 reply; 4+ messages in thread
From: Bjorn Helgaas @ 2017-02-15 23:56 UTC (permalink / raw)
  To: Prarit Bhargava; +Cc: linux-pci, mstowe, Bjorn Helgaas

On Wed, Feb 15, 2017 at 11:53:08AM -0500, Prarit Bhargava wrote:
> 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.

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.

> Signed-off-by: Prarit Bhargava <prarit@redhat.com>
> Cc: mstowe@redhat.com
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> ---
>  drivers/pci/msi.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
> index 50c5003295ca..3d709311052d 100644
> --- a/drivers/pci/msi.c
> +++ b/drivers/pci/msi.c
> @@ -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) {
> -- 
> 1.7.9.3
> 

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

* Re: [RESENT PATCH] PCI/MSI: Fix msi_desc->affinity memory leak when freeing MSI IRQs.
  2017-02-15 23:56 ` Bjorn Helgaas
@ 2017-02-16 12:47   ` Prarit Bhargava
  0 siblings, 0 replies; 4+ messages in thread
From: Prarit Bhargava @ 2017-02-16 12:47 UTC (permalink / raw)
  To: Linux PCI; +Cc: Bjorn Helgaas, Myron Stowe



On 02/15/2017 06:56 PM, Bjorn Helgaas wrote:
> On Wed, Feb 15, 2017 at 11:53:08AM -0500, Prarit Bhargava wrote:
>> 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.
> 
> 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 ...

> But I guess it's probably a longer term effort to clean that up.
> 

... there's a larger cleanup that's required here.

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

>> Signed-off-by: Prarit Bhargava <prarit@redhat.com>
>> Cc: mstowe@redhat.com
>> Cc: Bjorn Helgaas <bhelgaas@google.com>
>> ---
>>  drivers/pci/msi.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
>> index 50c5003295ca..3d709311052d 100644
>> --- a/drivers/pci/msi.c
>> +++ b/drivers/pci/msi.c
>> @@ -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) {
>> -- 
>> 1.7.9.3
>>

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

* Re: [RESENT PATCH] PCI/MSI: Fix msi_desc->affinity memory leak when freeing MSI IRQs.
  2017-02-15 16:53 [RESENT PATCH] PCI/MSI: Fix msi_desc->affinity memory leak when freeing MSI IRQs Prarit Bhargava
  2017-02-15 23:56 ` Bjorn Helgaas
@ 2017-02-17 21:47 ` Bjorn Helgaas
  1 sibling, 0 replies; 4+ messages in thread
From: Bjorn Helgaas @ 2017-02-17 21:47 UTC (permalink / raw)
  To: Prarit Bhargava; +Cc: linux-pci, mstowe, Bjorn Helgaas

On Wed, Feb 15, 2017 at 11:53:08AM -0500, Prarit Bhargava wrote:
> 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.
> 
> Signed-off-by: Prarit Bhargava <prarit@redhat.com>
> Cc: mstowe@redhat.com
> Cc: Bjorn Helgaas <bhelgaas@google.com>

Applied to pci/msi for v4.11, thanks, Prarit!

> ---
>  drivers/pci/msi.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
> index 50c5003295ca..3d709311052d 100644
> --- a/drivers/pci/msi.c
> +++ b/drivers/pci/msi.c
> @@ -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) {
> -- 
> 1.7.9.3
> 

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

end of thread, other threads:[~2017-02-17 21:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-15 16:53 [RESENT PATCH] PCI/MSI: Fix msi_desc->affinity memory leak when freeing MSI IRQs Prarit Bhargava
2017-02-15 23:56 ` Bjorn Helgaas
2017-02-16 12:47   ` Prarit Bhargava
2017-02-17 21:47 ` Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).