linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Fix memory leak in of_pci_get_host_bridge_resources
@ 2017-03-23  8:12 Jeffy Chen
  2017-03-23  8:12 ` [PATCH v2 1/2] PCI: return resource_entry in pci_add_resource helpers Jeffy Chen
  2017-03-23  9:00 ` [PATCH v2 0/2] Fix memory leak in of_pci_get_host_bridge_resources Shawn Lin
  0 siblings, 2 replies; 3+ messages in thread
From: Jeffy Chen @ 2017-03-23  8:12 UTC (permalink / raw)
  To: linux-kernel
  Cc: robh, toshi.kani, shawn.lin, briannorris, dianders, bhelgaas,
	dtor, Jeffy Chen, devicetree, linux-pci, Frank Rowand,
	Rob Herring

In of_pci_get_host_bridge_resources, we alloced some struct resource
variables, and they would cause memory leak since no where to free them.

Changes in v2:
Don't change the resource_list_create_entry's behavior.

Jeffy Chen (2):
  PCI: return resource_entry in pci_add_resource helpers
  of/pci: Fix memory leak in of_pci_get_host_bridge_resources

 drivers/of/of_pci.c | 57 +++++++++++++++++++++++------------------------------
 drivers/pci/bus.c   | 13 +++++++-----
 include/linux/pci.h |  8 +++++---
 3 files changed, 38 insertions(+), 40 deletions(-)

-- 
2.1.4

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

* [PATCH v2 1/2] PCI: return resource_entry in pci_add_resource helpers
  2017-03-23  8:12 [PATCH v2 0/2] Fix memory leak in of_pci_get_host_bridge_resources Jeffy Chen
@ 2017-03-23  8:12 ` Jeffy Chen
  2017-03-23  9:00 ` [PATCH v2 0/2] Fix memory leak in of_pci_get_host_bridge_resources Shawn Lin
  1 sibling, 0 replies; 3+ messages in thread
From: Jeffy Chen @ 2017-03-23  8:12 UTC (permalink / raw)
  To: linux-kernel
  Cc: robh, toshi.kani, shawn.lin, briannorris, dianders, bhelgaas,
	dtor, Jeffy Chen, linux-pci

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---

Changes in v2: None

 drivers/pci/bus.c   | 13 ++++++++-----
 include/linux/pci.h |  8 +++++---
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index bc56cf1..36a1861 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -17,25 +17,28 @@
 
 #include "pci.h"
 
-void pci_add_resource_offset(struct list_head *resources, struct resource *res,
-			     resource_size_t offset)
+struct resource_entry *pci_add_resource_offset(struct list_head *resources,
+					       struct resource *res,
+					       resource_size_t offset)
 {
 	struct resource_entry *entry;
 
 	entry = resource_list_create_entry(res, 0);
 	if (!entry) {
 		printk(KERN_ERR "PCI: can't add host bridge window %pR\n", res);
-		return;
+		return NULL;
 	}
 
 	entry->offset = offset;
 	resource_list_add_tail(entry, resources);
+	return entry;
 }
 EXPORT_SYMBOL(pci_add_resource_offset);
 
-void pci_add_resource(struct list_head *resources, struct resource *res)
+struct resource_entry *pci_add_resource(struct list_head *resources,
+					struct resource *res)
 {
-	pci_add_resource_offset(resources, res, 0);
+	return pci_add_resource_offset(resources, res, 0);
 }
 EXPORT_SYMBOL(pci_add_resource);
 
diff --git a/include/linux/pci.h b/include/linux/pci.h
index eb3da1a..ab16abe 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1167,9 +1167,11 @@ void pci_release_selected_regions(struct pci_dev *, int);
 /* drivers/pci/bus.c */
 struct pci_bus *pci_bus_get(struct pci_bus *bus);
 void pci_bus_put(struct pci_bus *bus);
-void pci_add_resource(struct list_head *resources, struct resource *res);
-void pci_add_resource_offset(struct list_head *resources, struct resource *res,
-			     resource_size_t offset);
+struct resource_entry *pci_add_resource(struct list_head *resources,
+					struct resource *res);
+struct resource_entry *pci_add_resource_offset(struct list_head *resources,
+					       struct resource *res,
+					       resource_size_t offset);
 void pci_free_resource_list(struct list_head *resources);
 void pci_bus_add_resource(struct pci_bus *bus, struct resource *res,
 			  unsigned int flags);
-- 
2.1.4

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

* Re: [PATCH v2 0/2] Fix memory leak in of_pci_get_host_bridge_resources
  2017-03-23  8:12 [PATCH v2 0/2] Fix memory leak in of_pci_get_host_bridge_resources Jeffy Chen
  2017-03-23  8:12 ` [PATCH v2 1/2] PCI: return resource_entry in pci_add_resource helpers Jeffy Chen
@ 2017-03-23  9:00 ` Shawn Lin
  1 sibling, 0 replies; 3+ messages in thread
From: Shawn Lin @ 2017-03-23  9:00 UTC (permalink / raw)
  To: Jeffy Chen
  Cc: linux-kernel, robh, toshi.kani, briannorris, dianders, bhelgaas,
	dtor, devicetree, linux-pci, Frank Rowand, Rob Herring

Hi Jeffy,

On 2017/3/23 16:12, Jeffy Chen wrote:
> In of_pci_get_host_bridge_resources, we alloced some struct resource
> variables, and they would cause memory leak since no where to free them.
>

Tested-by: Shawn Lin <shawn.lin@rock-chips.com>

> Changes in v2:
> Don't change the resource_list_create_entry's behavior.
>
> Jeffy Chen (2):
>   PCI: return resource_entry in pci_add_resource helpers
>   of/pci: Fix memory leak in of_pci_get_host_bridge_resources
>
>  drivers/of/of_pci.c | 57 +++++++++++++++++++++++------------------------------
>  drivers/pci/bus.c   | 13 +++++++-----
>  include/linux/pci.h |  8 +++++---
>  3 files changed, 38 insertions(+), 40 deletions(-)
>

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

end of thread, other threads:[~2017-03-23  9:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-23  8:12 [PATCH v2 0/2] Fix memory leak in of_pci_get_host_bridge_resources Jeffy Chen
2017-03-23  8:12 ` [PATCH v2 1/2] PCI: return resource_entry in pci_add_resource helpers Jeffy Chen
2017-03-23  9:00 ` [PATCH v2 0/2] Fix memory leak in of_pci_get_host_bridge_resources Shawn Lin

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