All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Haren Myneni" <haren@linux.ibm.com>
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: Mon, 21 Sep 2026 03:44:29 +0000	[thread overview]
Message-ID: <20260921034430.359EC1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260921033156.991481-1-haren@linux.ibm.com>

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.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260921033156.991481-1-haren@linux.ibm.com?part=1

  parent reply	other threads:[~2026-09-21  3:44 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 ` sashiko-bot [this message]
2026-09-22 18:02   ` [PATCH v2 1/2] drivers/of: Add of_detach_node_no_notify() Haren Myneni

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=20260921034430.359EC1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=haren@linux.ibm.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.