All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] ibmebus: fix device reference leaks in sysfs interface
@ 2016-11-01 15:26 Johan Hovold
  2016-11-01 15:26 ` [PATCH 2/4] ibmebus: fix further device reference leaks Johan Hovold
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Johan Hovold @ 2016-11-01 15:26 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linuxppc-dev, Johan Hovold

Make sure to drop any reference taken by bus_find_device() in the sysfs
callbacks that are used to create and destroy devices based on
device-tree entries.

Fixes: 6bccf755ff53 ("[POWERPC] ibmebus: dynamic addition/removal...)
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 arch/powerpc/kernel/ibmebus.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/ibmebus.c b/arch/powerpc/kernel/ibmebus.c
index 6ca9a2ffaac7..c7d3ff7e101c 100644
--- a/arch/powerpc/kernel/ibmebus.c
+++ b/arch/powerpc/kernel/ibmebus.c
@@ -262,6 +262,7 @@ static ssize_t ibmebus_store_probe(struct bus_type *bus,
 				   const char *buf, size_t count)
 {
 	struct device_node *dn = NULL;
+	struct device *dev;
 	char *path;
 	ssize_t rc = 0;
 
@@ -269,8 +270,10 @@ static ssize_t ibmebus_store_probe(struct bus_type *bus,
 	if (!path)
 		return -ENOMEM;
 
-	if (bus_find_device(&ibmebus_bus_type, NULL, path,
-			    ibmebus_match_path)) {
+	dev = bus_find_device(&ibmebus_bus_type, NULL, path,
+			      ibmebus_match_path);
+	if (dev) {
+		put_device(dev);
 		printk(KERN_WARNING "%s: %s has already been probed\n",
 		       __func__, path);
 		rc = -EEXIST;
@@ -307,6 +310,7 @@ static ssize_t ibmebus_store_remove(struct bus_type *bus,
 	if ((dev = bus_find_device(&ibmebus_bus_type, NULL, path,
 				   ibmebus_match_path))) {
 		of_device_unregister(to_platform_device(dev));
+		put_device(dev);
 
 		kfree(path);
 		return count;
-- 
2.7.3

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

* [PATCH 2/4] ibmebus: fix further device reference leaks
  2016-11-01 15:26 [PATCH 1/4] ibmebus: fix device reference leaks in sysfs interface Johan Hovold
@ 2016-11-01 15:26 ` Johan Hovold
  2016-11-14 12:17   ` [2/4] " Michael Ellerman
  2016-11-01 15:26 ` [PATCH 3/4] powerpc/vio: clarify vio_find_node reference counting Johan Hovold
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Johan Hovold @ 2016-11-01 15:26 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linuxppc-dev, Johan Hovold

Make sure to drop any reference taken by bus_find_device() when creating
devices during init and driver registration.

Fixes: 55347cc9962f ("[POWERPC] ibmebus: Add device creation...)
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 arch/powerpc/kernel/ibmebus.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/ibmebus.c b/arch/powerpc/kernel/ibmebus.c
index c7d3ff7e101c..35f5244782d9 100644
--- a/arch/powerpc/kernel/ibmebus.c
+++ b/arch/powerpc/kernel/ibmebus.c
@@ -180,6 +180,7 @@ static int ibmebus_create_device(struct device_node *dn)
 static int ibmebus_create_devices(const struct of_device_id *matches)
 {
 	struct device_node *root, *child;
+	struct device *dev;
 	int ret = 0;
 
 	root = of_find_node_by_path("/");
@@ -188,9 +189,12 @@ static int ibmebus_create_devices(const struct of_device_id *matches)
 		if (!of_match_node(matches, child))
 			continue;
 
-		if (bus_find_device(&ibmebus_bus_type, NULL, child,
-				    ibmebus_match_node))
+		dev = bus_find_device(&ibmebus_bus_type, NULL, child,
+				      ibmebus_match_node);
+		if (dev) {
+			put_device(dev);
 			continue;
+		}
 
 		ret = ibmebus_create_device(child);
 		if (ret) {
-- 
2.7.3

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

* [PATCH 3/4] powerpc/vio: clarify vio_find_node reference counting
  2016-11-01 15:26 [PATCH 1/4] ibmebus: fix device reference leaks in sysfs interface Johan Hovold
  2016-11-01 15:26 ` [PATCH 2/4] ibmebus: fix further device reference leaks Johan Hovold
@ 2016-11-01 15:26 ` Johan Hovold
  2016-11-14 12:17   ` [3/4] " Michael Ellerman
  2016-11-01 15:26 ` [PATCH 4/4] powerpc/pci: fix device reference leaks Johan Hovold
  2016-11-14 12:17 ` [1/4] ibmebus: fix device reference leaks in sysfs interface Michael Ellerman
  3 siblings, 1 reply; 8+ messages in thread
From: Johan Hovold @ 2016-11-01 15:26 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linuxppc-dev, Johan Hovold

Add comment clarifying that vio_find_node() takes a reference to the
embedded struct device which needs to be dropped after use.

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 arch/powerpc/kernel/vio.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index b3813ddb2fb4..2c8fb3ec989e 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -1648,6 +1648,9 @@ static struct vio_dev *vio_find_name(const char *name)
 /**
  * vio_find_node - find an already-registered vio_dev
  * @vnode: device_node of the virtual device we're looking for
+ *
+ * Takes a reference to the embedded struct device which needs to be dropped
+ * after use.
  */
 struct vio_dev *vio_find_node(struct device_node *vnode)
 {
-- 
2.7.3

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

* [PATCH 4/4] powerpc/pci: fix device reference leaks
  2016-11-01 15:26 [PATCH 1/4] ibmebus: fix device reference leaks in sysfs interface Johan Hovold
  2016-11-01 15:26 ` [PATCH 2/4] ibmebus: fix further device reference leaks Johan Hovold
  2016-11-01 15:26 ` [PATCH 3/4] powerpc/vio: clarify vio_find_node reference counting Johan Hovold
@ 2016-11-01 15:26 ` Johan Hovold
  2016-11-14 12:17   ` [4/4] " Michael Ellerman
  2016-11-14 12:17 ` [1/4] ibmebus: fix device reference leaks in sysfs interface Michael Ellerman
  3 siblings, 1 reply; 8+ messages in thread
From: Johan Hovold @ 2016-11-01 15:26 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linuxppc-dev, Johan Hovold

Make sure to drop any device reference taken by vio_find_node() when
adding and removing virtual I/O slots.

Fixes: 5eeb8c63a38f ("[PATCH] PCI Hotplug: rpaphp: Move VIO...")
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/pci/hotplug/rpadlpar_core.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c
index dc67f39779ec..c614ff7c3bc3 100644
--- a/drivers/pci/hotplug/rpadlpar_core.c
+++ b/drivers/pci/hotplug/rpadlpar_core.c
@@ -257,8 +257,13 @@ static int dlpar_add_phb(char *drc_name, struct device_node *dn)
 
 static int dlpar_add_vio_slot(char *drc_name, struct device_node *dn)
 {
-	if (vio_find_node(dn))
+	struct vio_dev *vio_dev;
+
+	vio_dev = vio_find_node(dn);
+	if (vio_dev) {
+		put_device(&vio_dev->dev);
 		return -EINVAL;
+	}
 
 	if (!vio_register_device_node(dn)) {
 		printk(KERN_ERR
@@ -334,6 +339,9 @@ static int dlpar_remove_vio_slot(char *drc_name, struct device_node *dn)
 		return -EINVAL;
 
 	vio_unregister_device(vio_dev);
+
+	put_device(&vio_dev->dev);
+
 	return 0;
 }
 
-- 
2.7.3

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

* Re: [1/4] ibmebus: fix device reference leaks in sysfs interface
  2016-11-01 15:26 [PATCH 1/4] ibmebus: fix device reference leaks in sysfs interface Johan Hovold
                   ` (2 preceding siblings ...)
  2016-11-01 15:26 ` [PATCH 4/4] powerpc/pci: fix device reference leaks Johan Hovold
@ 2016-11-14 12:17 ` Michael Ellerman
  3 siblings, 0 replies; 8+ messages in thread
From: Michael Ellerman @ 2016-11-14 12:17 UTC (permalink / raw)
  To: Johan Hovold, Benjamin Herrenschmidt, Paul Mackerras
  Cc: linuxppc-dev, Johan Hovold

On Tue, 2016-01-11 at 15:26:00 UTC, Johan Hovold wrote:
> Make sure to drop any reference taken by bus_find_device() in the sysfs
> callbacks that are used to create and destroy devices based on
> device-tree entries.
> 
> Fixes: 6bccf755ff53 ("[POWERPC] ibmebus: dynamic addition/removal...)
> Signed-off-by: Johan Hovold <johan@kernel.org>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/fe0f3168169f7c34c29b0cf0c489f1

cheers

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

* Re: [2/4] ibmebus: fix further device reference leaks
  2016-11-01 15:26 ` [PATCH 2/4] ibmebus: fix further device reference leaks Johan Hovold
@ 2016-11-14 12:17   ` Michael Ellerman
  0 siblings, 0 replies; 8+ messages in thread
From: Michael Ellerman @ 2016-11-14 12:17 UTC (permalink / raw)
  To: Johan Hovold, Benjamin Herrenschmidt, Paul Mackerras
  Cc: linuxppc-dev, Johan Hovold

On Tue, 2016-01-11 at 15:26:01 UTC, Johan Hovold wrote:
> Make sure to drop any reference taken by bus_find_device() when creating
> devices during init and driver registration.
> 
> Fixes: 55347cc9962f ("[POWERPC] ibmebus: Add device creation...)
> Signed-off-by: Johan Hovold <johan@kernel.org>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/815a7141c4d1b11610dccb7fcbb386

cheers

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

* Re: [3/4] powerpc/vio: clarify vio_find_node reference counting
  2016-11-01 15:26 ` [PATCH 3/4] powerpc/vio: clarify vio_find_node reference counting Johan Hovold
@ 2016-11-14 12:17   ` Michael Ellerman
  0 siblings, 0 replies; 8+ messages in thread
From: Michael Ellerman @ 2016-11-14 12:17 UTC (permalink / raw)
  To: Johan Hovold, Benjamin Herrenschmidt, Paul Mackerras
  Cc: linuxppc-dev, Johan Hovold

On Tue, 2016-01-11 at 15:26:02 UTC, Johan Hovold wrote:
> Add comment clarifying that vio_find_node() takes a reference to the
> embedded struct device which needs to be dropped after use.
> 
> Signed-off-by: Johan Hovold <johan@kernel.org>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/e8cfb7e7c3b2be8a4c2241b5da2ae6

cheers

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

* Re: [4/4] powerpc/pci: fix device reference leaks
  2016-11-01 15:26 ` [PATCH 4/4] powerpc/pci: fix device reference leaks Johan Hovold
@ 2016-11-14 12:17   ` Michael Ellerman
  0 siblings, 0 replies; 8+ messages in thread
From: Michael Ellerman @ 2016-11-14 12:17 UTC (permalink / raw)
  To: Johan Hovold, Benjamin Herrenschmidt, Paul Mackerras
  Cc: linuxppc-dev, Johan Hovold

On Tue, 2016-01-11 at 15:26:03 UTC, Johan Hovold wrote:
> Make sure to drop any device reference taken by vio_find_node() when
> adding and removing virtual I/O slots.
> 
> Fixes: 5eeb8c63a38f ("[PATCH] PCI Hotplug: rpaphp: Move VIO...")
> Signed-off-by: Johan Hovold <johan@kernel.org>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/99e5cde5eae78bef95bfe7c16ccda8

cheers

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

end of thread, other threads:[~2016-11-14 12:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-01 15:26 [PATCH 1/4] ibmebus: fix device reference leaks in sysfs interface Johan Hovold
2016-11-01 15:26 ` [PATCH 2/4] ibmebus: fix further device reference leaks Johan Hovold
2016-11-14 12:17   ` [2/4] " Michael Ellerman
2016-11-01 15:26 ` [PATCH 3/4] powerpc/vio: clarify vio_find_node reference counting Johan Hovold
2016-11-14 12:17   ` [3/4] " Michael Ellerman
2016-11-01 15:26 ` [PATCH 4/4] powerpc/pci: fix device reference leaks Johan Hovold
2016-11-14 12:17   ` [4/4] " Michael Ellerman
2016-11-14 12:17 ` [1/4] ibmebus: fix device reference leaks in sysfs interface Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.