Re: [PATCH v2 1/3] driver core: platform: remove software node on release()
From: Dmitry Torokhov
Date: Sun Apr 26 2026 - 00:24:48 EST
On Fri, Apr 24, 2026 at 02:26:38PM +0200, Bartosz Golaszewski wrote:
> On Thu, Apr 23, 2026 at 7:32 PM Dmitry Torokhov
> <dmitry.torokhov@xxxxxxxxx> wrote:
> >
> > >
> > > + /*
> > > + * If the primary firmware node is a software node and there's no
> > > + * secondary firmware node, the primary will be affected by the call
> > > + * to device_remove_software_node() in platform_device_release() and
> > > + * its reference count will be dropped by one. Take another reference
> > > + * here to make it have no effect.
> > > + */
> > > + if (is_software_node(pdevinfo->fwnode) && !pdevinfo->swnode)
> > > + fwnode_handle_get(pdevinfo->fwnode);
> >
> > It is possible to pass already registered node in pdevinfo->swnode
> > (because device_add_software_node() can handle this just fine). In this
> > case we also need to take an extra reference (or figure out whether we
> > need to drop the reference when removing the device).
> >
>
> But device_add_software_node() checks if the software node is
> registered and - if so - just bumps the reference so the effect is the
> same as when it registers the swnode.
Ah, yes, you are right.
Still please check sashiko review - I think some of the concerns about
error unwinding are correct.
Thanks.
--
Dmitry