Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Abdurrahman Hussain" <abdurrahman@nexthop.ai>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v6 04/10] of/overlay: look up absolute target-paths absolutely
Date: Wed, 05 Aug 2026 20:40:09 +0000	[thread overview]
Message-ID: <20260805204009.CF3891F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260805-nh-of-alias-overlay-v6-4-74f21d440819@nexthop.ai>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [Medium] Pre-existing memory leak of target and overlay device node references occurs on the error paths of `init_overlay_changeset()`.
--

--- Patch [4]: [PATCH v6 04/10] of/overlay: look up absolute target-paths absolutely ---
commit 28d3c18ff8d649fd8af8d895999493b24c338fa1
Author: Abdurrahman Hussain <abdurrahman@nexthop.ai>

of/overlay: look up absolute target-paths absolutely

This commit updates find_target() to resolve non-empty target-path properties
as absolute paths from the live-tree root rather than appending them to the
target base. Empty target-path values still resolve to the target base itself.
The documentation for init_overlay_changeset() and of_overlay_apply() is
updated to reflect this new behavior.

> diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c
> index 08d5351746be6..74aea704835ac 100644
> --- a/drivers/of/overlay.c
> +++ b/drivers/of/overlay.c

[ ... ]

> @@ -737,7 +731,9 @@ static struct device_node *find_target(const struct device_node *info_node,
>  /**
>   * init_overlay_changeset() - initialize overlay changeset from overlay tree
>   * @ovcs:		Overlay changeset to build
> - * @target_base:	Point to the target node to apply overlay
> + * @target_base:	Target for fragments with an empty "target-path";
> + *			fragments with a non-empty "target-path" resolve
> + *			absolutely and ignore @target_base
>   *
>   * Initialize @ovcs.  Populate @ovcs->fragments with node information from
>   * the top level of @overlay_root.  The relevant top level nodes are the

[Severity: Medium]
This is a pre-existing issue, but does init_overlay_changeset() leak
device node references when an error occurs during fragment processing?

Looking at init_overlay_changeset(), if find_target() fails (or if the
__symbols__ target is missing), it jumps to err_out without updating
ovcs->count:

		fragment->target = find_target(node, target_base);
		if (!fragment->target) {
			of_node_put(fragment->overlay);
			ret = -EINVAL;
			of_node_put(node);
			goto err_out;
		}

Because ovcs->count is only updated to the successfully processed count
at the very end of the function, it remains 0 during the error return.

When the caller subsequently runs free_overlay_changeset() to clean up the
partially initialized changeset, its cleanup loop is skipped entirely because
ovcs->count is 0:

	for (i = 0; i < ovcs->count; i++) {
		of_node_put(ovcs->fragments[i].target);
		of_node_put(ovcs->fragments[i].overlay);
	}

Would this permanently leak the node references for any fragments that were
successfully processed before the failure occurred?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260805-nh-of-alias-overlay-v6-0-74f21d440819@nexthop.ai?part=4

  reply	other threads:[~2026-08-05 20:40 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-05 20:30 [PATCH v6 00/10] of: teach overlay code to keep /aliases in sync Abdurrahman Hussain
2026-08-05 20:31 ` [PATCH v6 01/10] of: fix out-of-bounds read in of_alias_scan() stem parser Abdurrahman Hussain
2026-08-06  8:10   ` Geert Uytterhoeven
2026-08-05 20:31 ` [PATCH v6 02/10] of: hold a reference on of_aliases during alias path resolution Abdurrahman Hussain
2026-08-05 20:52   ` sashiko-bot
2026-08-05 20:31 ` [PATCH v6 03/10] of: update /aliases lookup on reconfig notifications Abdurrahman Hussain
2026-08-05 20:31 ` [PATCH v6 04/10] of/overlay: look up absolute target-paths absolutely Abdurrahman Hussain
2026-08-05 20:40   ` sashiko-bot [this message]
2026-08-05 20:31 ` [PATCH v6 05/10] of/overlay: put property on deadprops only after changeset add succeeds Abdurrahman Hussain
2026-08-05 20:45   ` sashiko-bot
2026-08-05 20:31 ` [PATCH v6 06/10] of/overlay: only treat a positive changeset id as registered Abdurrahman Hussain
2026-08-05 20:42   ` sashiko-bot
2026-08-06  7:52   ` Geert Uytterhoeven
2026-08-05 20:31 ` [PATCH v6 07/10] of/overlay: don't create "//" paths for fragments targeting the root Abdurrahman Hussain
2026-08-05 20:45   ` sashiko-bot
2026-08-05 20:31 ` [PATCH v6 08/10] of/overlay: return ERR_PTR from dup_and_fixup_symbol_prop() Abdurrahman Hussain
2026-08-05 20:31 ` [PATCH v6 09/10] of/overlay: rewrite /aliases path values to live-tree paths Abdurrahman Hussain
2026-08-05 20:31 ` [PATCH v6 10/10] of: unittest: cover /aliases updates from overlay apply/revert Abdurrahman Hussain

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=20260805204009.CF3891F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=abdurrahman@nexthop.ai \
    --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