From: "Rob Herring (Arm)" <robh@kernel.org>
To: Selby Mashiki <mashikiselby@gmail.com>
Cc: Saravana Kannan <saravanak@kernel.org>,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH] of: overlay: fix device_node leak when attaching node to changeset fails
Date: Thu, 19 Nov 2026 14:11:58 -0600 [thread overview]
Message-ID: <179511865293.69428.941600845556456809.robh@kernel.org> (raw)
In-Reply-To: <20261025180237.445403-1-mashikiselby@gmail.com>
On Sun, 25 Oct 2026 20:02:37 +0200, Selby Mashiki wrote:
> In add_changeset_node(), when creating a new target child node via
> __of_node_dup(), tchild is initialized with a reference count of 1. If
> of_changeset_attach_node() subsequently fails, add_changeset_node()
> returns the error without calling of_node_put(tchild), leaking the
> allocated device_node.
>
> Furthermore, because OF_OVERLAY is set on tchild before
> of_changeset_attach_node() is called, calling of_node_put(tchild) when
> tchild was never added to the changeset (and thus never had
> OF_OVERLAY_FREE_CSET set by __of_changeset_entry_destroy()) would cause
> of_node_release() to log a premature refcount zero error and skip
> freeing the node.
>
> Move of_node_set_flag(tchild, OF_OVERLAY) after
> of_changeset_attach_node() succeeds and call of_node_put(tchild) on the
> failure path, matching of_changeset_create_node().
>
> Fixes: 7c528e457d53 ("of: overlay: add missing of_node_put() after add new node to changeset")
> Fixes: 144552c78692 ("of: overlay: add tests to validate kfrees from overlay removal")
These don't look right to me, so I dropped them.
> Signed-off-by: Selby Mashiki <mashikiselby@gmail.com>
> ---
> drivers/of/overlay.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
Applied, thanks!
prev parent reply other threads:[~2026-11-19 20:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-25 18:02 [PATCH] of: overlay: fix device_node leak when attaching node to changeset fails Selby Mashiki
2026-11-02 10:49 ` Krzysztof Kozlowski
2026-11-19 20:11 ` Rob Herring (Arm) [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=179511865293.69428.941600845556456809.robh@kernel.org \
--to=robh@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mashikiselby@gmail.com \
--cc=saravanak@kernel.org \
/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