diff mbox

[4/6] driver core: Don't leak secondary fwnode on device removal

Message ID ef34b0d31d1fb9bc6a48a07d265fd103527b3f30.1469616641.git.lukas@wunner.de (mailing list archive)
State Accepted, archived
Delegated to: Rafael Wysocki
Headers show

Commit Message

Lukas Wunner July 28, 2016, 12:25 a.m. UTC
If device_add_property_set() is called for a device, a secondary fwnode
is allocated and assigned to the device but currently not freed once the
device is removed.

This can be triggered on Apple Macs if a Thunderbolt device is plugged
in on boot since Apple's NHI EFI driver sets a number of properties for
that device which are leaked on unplug.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Andreas Noever <andreas.noever@gmail.com>
Signed-off-by: Lukas Wunner <lukas@wunner.de>
---
 drivers/base/core.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Rafael J. Wysocki Aug. 17, 2016, 12:38 a.m. UTC | #1
On Thursday, July 28, 2016 02:25:41 AM Lukas Wunner wrote:
> If device_add_property_set() is called for a device, a secondary fwnode
> is allocated and assigned to the device but currently not freed once the
> device is removed.
> 
> This can be triggered on Apple Macs if a Thunderbolt device is plugged
> in on boot since Apple's NHI EFI driver sets a number of properties for
> that device which are leaked on unplug.
> 
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Andreas Noever <andreas.noever@gmail.com>
> Signed-off-by: Lukas Wunner <lukas@wunner.de>

ACK, or I can apply it directly if you want me to do that.

Thanks,
Rafael

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Lukas Wunner Aug. 30, 2016, 9:03 a.m. UTC | #2
On Wed, Aug 17, 2016 at 02:38:50AM +0200, Rafael J. Wysocki wrote:
> On Thursday, July 28, 2016 02:25:41 AM Lukas Wunner wrote:
> > If device_add_property_set() is called for a device, a secondary fwnode
> > is allocated and assigned to the device but currently not freed once the
> > device is removed.
> > 
> > This can be triggered on Apple Macs if a Thunderbolt device is plugged
> > in on boot since Apple's NHI EFI driver sets a number of properties for
> > that device which are leaked on unplug.
> > 
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> > Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Cc: Andreas Noever <andreas.noever@gmail.com>
> > Signed-off-by: Lukas Wunner <lukas@wunner.de>
> 
> ACK, or I can apply it directly if you want me to do that.

Yes, if you could apply it directly I'd be grateful.

Thanks!

Lukas
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Rafael J. Wysocki Sept. 12, 2016, 10:03 p.m. UTC | #3
On Tuesday, August 30, 2016 11:03:25 AM Lukas Wunner wrote:
> On Wed, Aug 17, 2016 at 02:38:50AM +0200, Rafael J. Wysocki wrote:
> > On Thursday, July 28, 2016 02:25:41 AM Lukas Wunner wrote:
> > > If device_add_property_set() is called for a device, a secondary fwnode
> > > is allocated and assigned to the device but currently not freed once the
> > > device is removed.
> > > 
> > > This can be triggered on Apple Macs if a Thunderbolt device is plugged
> > > in on boot since Apple's NHI EFI driver sets a number of properties for
> > > that device which are leaked on unplug.
> > > 
> > > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > > Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > > Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> > > Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > > Cc: Andreas Noever <andreas.noever@gmail.com>
> > > Signed-off-by: Lukas Wunner <lukas@wunner.de>
> > 
> > ACK, or I can apply it directly if you want me to do that.
> 
> Yes, if you could apply it directly I'd be grateful.

Applied.

Thanks,
Rafael

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 0a8bdad..70c5be5 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1266,6 +1266,7 @@  void device_del(struct device *dev)
 	bus_remove_device(dev);
 	device_pm_remove(dev);
 	driver_deferred_probe_del(dev);
+	device_remove_properties(dev);
 
 	/* Notify the platform of the removal, in case they
 	 * need to do anything...