From: Haren Myneni <haren@linux.ibm.com>
To: sashiko-reviews@lists.linux.dev
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v2 1/2] drivers/of: Add of_detach_node_no_notify()
Date: Tue, 22 Sep 2026 11:02:11 -0700 [thread overview]
Message-ID: <60bdd0019df887db393585f14c520e01599ccc3d.camel@linux.ibm.com> (raw)
In-Reply-To: <20260921034430.359EC1F000FF@smtp.kernel.org>
On Mon, 2026-09-21 at 03:44 +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue(s) to consider:
> - [Medium] of: resource leak when using of_detach_node_no_notify()
> for rollback
> --
>
> commit 32bc441a65c0469af8bda8ae3a3847daa98db314
> Author: Haren Myneni <haren@linux.ibm.com>
>
> drivers/of: Add of_detach_node_no_notify()
>
> This commit introduces the of_detach_node_no_notify() interface to
> allow
> callers to remove a device tree node without triggering the
> corresponding
> detach notifiers. This is intended to handle rollback scenarios where
> adding nodes in a changeset fails after partially attaching them.
>
> > diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
> > index 744ce0e1eb24a..fc6f22371a97c 100644
> > --- a/drivers/of/dynamic.c
> > +++ b/drivers/of/dynamic.c
>
> [ ... ]
>
> > @@ -318,6 +318,22 @@ int of_detach_node(struct device_node *np)
> > }
> > EXPORT_SYMBOL_GPL(of_detach_node);
> >
> > +/**
> > + * of_detach_node_no_notify() - "Unplug" a node from the device
> > + * and return without running notifiers.
> > + * @np: Pointer to the caller's Device Node
> > + */
> > +int of_detach_node_no_notify(struct device_node *np)
> > +{
> > + mutex_lock(&of_mutex);
> > + if (!of_node_check_flag(np, OF_DETACHED))
> > + __of_detach_node(np);
> > + mutex_unlock(&of_mutex);
> > +
> > + return 0;
> > +}
>
> [Severity: Medium]
> Does bypassing the OF_RECONFIG_DETACH_NODE notifier during error
> rollback
> cause resource leaks?
>
> If a caller attempts to dynamically add a device tree node and the
> OF_RECONFIG_ATTACH_NODE notifier chain fails midway, calling this new
> API
> to roll back the attachment will skip the detach notifiers.
>
> This fundamentally breaks subsystem teardown symmetry, which means
> any
> previously successful attach notifiers in the chain might permanently
> leak
> their allocated resources, such as platform_device instances.
of_detach_node_no_notify() is called per node and only if the attached
node notifier is failed. So up to the caller whether to use this or
of_detach_node().
prev parent reply other threads:[~2026-09-22 18:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 3:31 [PATCH v2 1/2] drivers/of: Add of_detach_node_no_notify() Haren Myneni
2026-09-21 3:31 ` [PATCH v2 2/2] powerpc/pseries/dlpar: Remove DT entries if failure from CPU ADD notifier Haren Myneni
2026-09-21 3:47 ` sashiko-bot
2026-09-22 23:32 ` Haren Myneni
2026-09-21 3:44 ` [PATCH v2 1/2] drivers/of: Add of_detach_node_no_notify() sashiko-bot
2026-09-22 18:02 ` Haren Myneni [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=60bdd0019df887db393585f14c520e01599ccc3d.camel@linux.ibm.com \
--to=haren@linux.ibm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).