Re: [PATCH 1/3] driver core: swnode: only release owned secondary software nodes
From: Danilo Krummrich
Date: Sat Dec 05 2026 - 18:04:04 EST
On Thu Dec 3, 2026 at 2:34 AM CET, Dmitry Torokhov wrote:
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 44f79f427b6b..673dc5941019 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -5250,12 +5250,19 @@ void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
> dev->fwnode = fwnode;
> } else {
> if (fwnode_is_primary(fn)) {
> - dev->fwnode = fn->secondary;
> -
> - /* Skip nullifying fn->secondary if the primary is shared */
> - if (parent && fn == parent->fwnode)
> + /*
> + * If the primary fwnode is shared with the parent and
> + * this device did not attach the secondary node, clear
> + * dev->fwnode without leaving it pointing to the
> + * parent's secondary node or modifying fn->secondary.
> + */
> + if (parent && fn == parent->fwnode &&
> + !dev_swnode_added(dev)) {
> + dev->fwnode = NULL;
> return;
> + }
I think the Sashiko report [1] is valid (though it was present before this patch
as well).
I think we need to preserve the borrowed secondary when detaching a non-shared
primary, and ensure device release drops only references the device actually
owns.
[1] https://sashiko.dev/#/patchset/20261202-swnode-shared-primary-fix-v1-0-7ff23caaa1ed%40gmail.com