Skip to content

Commit

Permalink
software node: Allow node addition to already existing device
Browse files Browse the repository at this point in the history
If the node is added to an already exiting device, the node
needs to be also linked to the device separately.

This will make sure the reference count is kept in balance
also when the node is injected to a device afterwards.

Fixes: e68d011 ("software node: Introduce device_add_software_node()")
Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210414075438.64547-1-heikki.krogerus@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Heikki Krogerus authored and Greg Kroah-Hartman committed Apr 15, 2021
1 parent 586c402 commit b622b24
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/base/swnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,7 @@ int device_add_software_node(struct device *dev, const struct software_node *nod
}

set_secondary_fwnode(dev, &swnode->fwnode);
software_node_notify(dev, KOBJ_ADD);

return 0;
}
Expand Down Expand Up @@ -1118,8 +1119,8 @@ int software_node_notify(struct device *dev, unsigned long action)

switch (action) {
case KOBJ_ADD:
ret = sysfs_create_link(&dev->kobj, &swnode->kobj,
"software_node");
ret = sysfs_create_link_nowarn(&dev->kobj, &swnode->kobj,
"software_node");
if (ret)
break;

Expand Down

0 comments on commit b622b24

Please sign in to comment.