• Jarkko Nikula's avatar
    device property: Track owner device of device property · 2a077f72
    Jarkko Nikula authored
    commit 5ab894ae upstream.
    Deletion of subdevice will remove device properties associated to parent
    when they share the same firmware node after commit 478573c9 (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
    		set_secondary_fwnode(dev, &p->fwnode)
    parent probe
    	read device properties
    	ACPI_COMPANION_SET(subdevice, ACPI_COMPANION(parent))
    parent remove
    			set_secondary_fwnode(dev, NULL);
    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
    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: 478573c9 (driver core: Don't leak secondary fwnode on device removal)
    Signed-off-by: default avatarJarkko Nikula <jarkko.nikula@linux.intel.com>
    Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>