]> git.baikalelectronics.ru Git - kernel.git/commit
device property: Track owner device of device property
authorJarkko Nikula <jarkko.nikula@linux.intel.com>
Mon, 9 Oct 2017 13:28:37 +0000 (16:28 +0300)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 10 Oct 2017 02:09:45 +0000 (04:09 +0200)
commit16b9b3903ae045cec4bb26f899cc1c825a909c89
tree72b7bbbfed94430c68f3cdbb77cf236bd2d66b3b
parentc1b31305bd9ced7f4232632fe8925af072cfcafa
device property: Track owner device of device property

Deletion of subdevice will remove device properties associated to parent
when they share the same firmware node after commit 1288c4246ac0 (driver
core: Don't leak secondary fwnode on device removal).  This was observed
with a driver adding subdevice that driver wasn't able to read device
properties after rmmod/modprobe cycle.

Consider the lifecycle of it:

parent device registration
ACPI_COMPANION_SET()
device_add_properties()
pset_copy_set()
set_secondary_fwnode(dev, &p->fwnode)
device_add()

parent probe
read device properties
ACPI_COMPANION_SET(subdevice, ACPI_COMPANION(parent))
device_add(subdevice)

parent remove
device_del(subdevice)
device_remove_properties()
set_secondary_fwnode(dev, NULL);
pset_free()

Parent device will have its primary firmware node pointing to an ACPI
node and secondary firmware node point to device properties.

ACPI_COMPANION_SET() call in parent probe will set the subdevice's
firmware node to point to the same 'struct fwnode_handle' and the
associated secondary firmware node, i.e. the device properties as the
parent.

When subdevice is deleted in parent remove that will remove those
device properties and attempt to read device properties in next
parent probe call will fail.

Fix this by tracking the owner device of device properties and delete
them only when owner device is being deleted.

Fixes: 1288c4246ac0 (driver core: Don't leak secondary fwnode on device removal)
Cc: 4.9+ <stable@vger.kernel.org> # 4.9+
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/property.c