linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pci: fix memory leak when virtio pci hotplug
@ 2021-03-21 15:29 Zhiqiang Liu
  2021-03-22  2:43 ` Wu Bo
  2021-03-23 18:24 ` Bjorn Helgaas
  0 siblings, 2 replies; 5+ messages in thread
From: Zhiqiang Liu @ 2021-03-21 15:29 UTC (permalink / raw)
  To: rjw, lenb, bhelgaas
  Cc: linux-acpi, linux-pci, linux-kernel, linfeilong, liuzhiqiang26, wubo (T)

From: Feilong Lin <linfeilong@huawei.com>

Repeated hot-plugging of pci devices for a virtual
machine driven by virtio, we found that there is a
leak in kmalloc-4k, which was confirmed as the memory
of the pci_device structure. Then we found out that
it was missing pci_dev_put() after pci_get_slot() in
enable_slot() of acpiphp_glue.c.

Signed-off-by: Feilong Lin <linfeilong@huawei.com>
Reviewed-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
---
 drivers/pci/hotplug/acpiphp_glue.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 3365c93abf0e..f031302ad401 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -533,6 +533,7 @@ static void enable_slot(struct acpiphp_slot *slot, bool bridge)
 			slot->flags &= ~SLOT_ENABLED;
 			continue;
 		}
+		pci_dev_put(dev);
 	}
 }

-- 
2.19.1



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

* Re: [PATCH] pci: fix memory leak when virtio pci hotplug
  2021-03-21 15:29 [PATCH] pci: fix memory leak when virtio pci hotplug Zhiqiang Liu
@ 2021-03-22  2:43 ` Wu Bo
  2021-03-23  8:14   ` Zhiqiang Liu
  2021-03-23 18:24 ` Bjorn Helgaas
  1 sibling, 1 reply; 5+ messages in thread
From: Wu Bo @ 2021-03-22  2:43 UTC (permalink / raw)
  To: Zhiqiang Liu, rjw, lenb, bhelgaas
  Cc: linux-acpi, linux-pci, linux-kernel, linfeilong

On 2021/3/21 23:29, Zhiqiang Liu wrote:
> From: Feilong Lin <linfeilong@huawei.com>
> 
> Repeated hot-plugging of pci devices for a virtual
> machine driven by virtio, we found that there is a
> leak in kmalloc-4k, which was confirmed as the memory
> of the pci_device structure. Then we found out that
> it was missing pci_dev_put() after pci_get_slot() in
> enable_slot() of acpiphp_glue.c.
> 
> Signed-off-by: Feilong Lin <linfeilong@huawei.com>
> Reviewed-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
> ---
>   drivers/pci/hotplug/acpiphp_glue.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
> index 3365c93abf0e..f031302ad401 100644
> --- a/drivers/pci/hotplug/acpiphp_glue.c
> +++ b/drivers/pci/hotplug/acpiphp_glue.c
> @@ -533,6 +533,7 @@ static void enable_slot(struct acpiphp_slot *slot, bool bridge)
>   			slot->flags &= ~SLOT_ENABLED;
>   			continue;
>   		}
> +		pci_dev_put(dev);
>   	}
>   }
> 
Reviewed-by: Wu Bo <wubo40@huawei.com>

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

* Re: [PATCH] pci: fix memory leak when virtio pci hotplug
  2021-03-22  2:43 ` Wu Bo
@ 2021-03-23  8:14   ` Zhiqiang Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Zhiqiang Liu @ 2021-03-23  8:14 UTC (permalink / raw)
  To: Wu Bo, rjw, lenb, bhelgaas
  Cc: linux-acpi, linux-pci, linux-kernel, linfeilong

friendly ping..

On 2021/3/22 10:43, Wu Bo wrote:
> On 2021/3/21 23:29, Zhiqiang Liu wrote:
>> From: Feilong Lin <linfeilong@huawei.com>
>>
>> Repeated hot-plugging of pci devices for a virtual
>> machine driven by virtio, we found that there is a
>> leak in kmalloc-4k, which was confirmed as the memory
>> of the pci_device structure. Then we found out that
>> it was missing pci_dev_put() after pci_get_slot() in
>> enable_slot() of acpiphp_glue.c.
>>
>> Signed-off-by: Feilong Lin <linfeilong@huawei.com>
>> Reviewed-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
>> ---
>>   drivers/pci/hotplug/acpiphp_glue.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
>> index 3365c93abf0e..f031302ad401 100644
>> --- a/drivers/pci/hotplug/acpiphp_glue.c
>> +++ b/drivers/pci/hotplug/acpiphp_glue.c
>> @@ -533,6 +533,7 @@ static void enable_slot(struct acpiphp_slot *slot, bool bridge)
>>               slot->flags &= ~SLOT_ENABLED;
>>               continue;
>>           }
>> +        pci_dev_put(dev);
>>       }
>>   }
>>
> Reviewed-by: Wu Bo <wubo40@huawei.com>
>
> .


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

* Re: [PATCH] pci: fix memory leak when virtio pci hotplug
  2021-03-21 15:29 [PATCH] pci: fix memory leak when virtio pci hotplug Zhiqiang Liu
  2021-03-22  2:43 ` Wu Bo
@ 2021-03-23 18:24 ` Bjorn Helgaas
  2021-03-25  0:52   ` Zhiqiang Liu
  1 sibling, 1 reply; 5+ messages in thread
From: Bjorn Helgaas @ 2021-03-23 18:24 UTC (permalink / raw)
  To: Zhiqiang Liu
  Cc: rjw, lenb, bhelgaas, linux-acpi, linux-pci, linux-kernel,
	linfeilong, wubo (T)

On Sun, Mar 21, 2021 at 11:29:30PM +0800, Zhiqiang Liu wrote:
> From: Feilong Lin <linfeilong@huawei.com>
> 
> Repeated hot-plugging of pci devices for a virtual
> machine driven by virtio, we found that there is a
> leak in kmalloc-4k, which was confirmed as the memory
> of the pci_device structure. Then we found out that
> it was missing pci_dev_put() after pci_get_slot() in
> enable_slot() of acpiphp_glue.c.
> 
> Signed-off-by: Feilong Lin <linfeilong@huawei.com>
> Reviewed-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>

Since this came from you, Zhiqiang, it needs a signed-off-by (not just
a reviewed-by) from you.  See
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=v5.11#n361

Also see
https://lore.kernel.org/r/20171026223701.GA25649@bhelgaas-glaptop.roam.corp.google.com
and

  - Wrap commit log to fill 80 columns
  - s/pci/PCI/ (subject and commit log)
  - Run "git log --oneline drivers/pci/hotplug/acpiphp_glue.c".  It's
    not completely consistent, but at least match the style of one of
    them.

There is no "pci_device" structure.  I think you mean the "struct
pci_dev".

The commit log doesn't actually say what the patch does.  It's obvious
from the patch, but it should say in the commit log.  Look at previous
commit logs to see how they do it.

> ---
>  drivers/pci/hotplug/acpiphp_glue.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
> index 3365c93abf0e..f031302ad401 100644
> --- a/drivers/pci/hotplug/acpiphp_glue.c
> +++ b/drivers/pci/hotplug/acpiphp_glue.c
> @@ -533,6 +533,7 @@ static void enable_slot(struct acpiphp_slot *slot, bool bridge)
>  			slot->flags &= ~SLOT_ENABLED;
>  			continue;
>  		}
> +		pci_dev_put(dev);
>  	}
>  }
> 
> -- 
> 2.19.1
> 
> 

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

* Re: [PATCH] pci: fix memory leak when virtio pci hotplug
  2021-03-23 18:24 ` Bjorn Helgaas
@ 2021-03-25  0:52   ` Zhiqiang Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Zhiqiang Liu @ 2021-03-25  0:52 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: rjw, lenb, bhelgaas, linux-acpi, linux-pci, linux-kernel,
	linfeilong, wubo (T)

Thanks for your suggestion.

I will rewrite the commit log and send the v2 patch.


On 2021/3/24 2:24, Bjorn Helgaas wrote:
> On Sun, Mar 21, 2021 at 11:29:30PM +0800, Zhiqiang Liu wrote:
>> From: Feilong Lin <linfeilong@huawei.com>
>>
>> Repeated hot-plugging of pci devices for a virtual
>> machine driven by virtio, we found that there is a
>> leak in kmalloc-4k, which was confirmed as the memory
>> of the pci_device structure. Then we found out that
>> it was missing pci_dev_put() after pci_get_slot() in
>> enable_slot() of acpiphp_glue.c.
>>
>> Signed-off-by: Feilong Lin <linfeilong@huawei.com>
>> Reviewed-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
> Since this came from you, Zhiqiang, it needs a signed-off-by (not just
> a reviewed-by) from you.  See
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=v5.11#n361
>
> Also see
> https://lore.kernel.org/r/20171026223701.GA25649@bhelgaas-glaptop.roam.corp.google.com
> and
>
>   - Wrap commit log to fill 80 columns
>   - s/pci/PCI/ (subject and commit log)
>   - Run "git log --oneline drivers/pci/hotplug/acpiphp_glue.c".  It's
>     not completely consistent, but at least match the style of one of
>     them.
>
> There is no "pci_device" structure.  I think you mean the "struct
> pci_dev".
>
> The commit log doesn't actually say what the patch does.  It's obvious
> from the patch, but it should say in the commit log.  Look at previous
> commit logs to see how they do it.
>
>> ---
>>  drivers/pci/hotplug/acpiphp_glue.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
>> index 3365c93abf0e..f031302ad401 100644
>> --- a/drivers/pci/hotplug/acpiphp_glue.c
>> +++ b/drivers/pci/hotplug/acpiphp_glue.c
>> @@ -533,6 +533,7 @@ static void enable_slot(struct acpiphp_slot *slot, bool bridge)
>>  			slot->flags &= ~SLOT_ENABLED;
>>  			continue;
>>  		}
>> +		pci_dev_put(dev);
>>  	}
>>  }
>>
>> -- 
>> 2.19.1
>>
>>
> .


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

end of thread, other threads:[~2021-03-25  0:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-21 15:29 [PATCH] pci: fix memory leak when virtio pci hotplug Zhiqiang Liu
2021-03-22  2:43 ` Wu Bo
2021-03-23  8:14   ` Zhiqiang Liu
2021-03-23 18:24 ` Bjorn Helgaas
2021-03-25  0:52   ` Zhiqiang Liu

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