All of lore.kernel.org
 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 07/10] of/overlay: don't create "//" paths for fragments targeting the root
Date: Wed, 05 Aug 2026 20:45:12 +0000	[thread overview]
Message-ID: <20260805204513.806C41F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260805-nh-of-alias-overlay-v6-7-74f21d440819@nexthop.ai>

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

Pre-existing issues:
- [High] Node reference leak for initialized fragments if find_target() fails in init_overlay_changeset().
--

--- Patch [7]: [PATCH v6 07/10] of/overlay: don't create "//" paths for fragments targeting the root ---
commit 160c0459de49f61664940cc0b23bceacbf1b3082
Author: Abdurrahman Hussain <abdurrahman@nexthop.ai>

of/overlay: don't create "//" paths for fragments targeting the root
    
dup_and_fixup_symbol_prop() rewrites a symbol value by replacing its
"/fragment/__overlay__" prefix with the fragment's target path. When
the fragment targets the root node the target path is "/" and the
result starts with "//", which __of_find_node_by_full_path() cannot
resolve.
    
Drop the target path when it is the root and the tail is non-empty. A
value naming the fragment root itself (empty tail) keeps the "/".

> diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c
> index 9b9f198a1d70a..89a9fe6d6e786 100644
> --- a/drivers/of/overlay.c
> +++ b/drivers/of/overlay.c
> @@ -256,6 +256,9 @@ static struct property *dup_and_fixup_symbol_prop(
>  	if (!target_path)
>  		return NULL;
>  	target_path_len = strlen(target_path);
> +	/* a root target renders as "/"; drop it to avoid "//" results */
> +	if (target_path_len == 1 && target_path[0] == '/' && path_tail_len)
> +		target_path_len = 0;
>  
>  	new_prop = kzalloc_obj(*new_prop);
>  	if (!new_prop)

[ ... ]

> @@ -804,13 +804,13 @@ static int init_overlay_changeset(struct overlay_changeset *ovcs,
>  	cnt = 0;
>  	for_each_child_of_node(ovcs->overlay_root, node) {
>  		overlay_node = of_get_child_by_name(node, "__overlay__");
>  		if (!overlay_node)
>  			continue;
>  
>  		fragment = &fragments[cnt];
>  		fragment->overlay = overlay_node;
>  		fragment->target = find_target(node, target_base);
>  		if (!fragment->target) {
>  			of_node_put(fragment->overlay);
>  			ret = -EINVAL;
>  			of_node_put(node);
>  			goto err_out;
>  		}

[Severity: High]
This is a pre-existing issue, but does this jump to err_out leak device
node references if previous fragments were already successfully populated?

If a subsequent fragment's find_target() fails (e.g., due to an invalid target
path in the overlay), the function jumps to err_out without updating
ovcs->count.

Because ovcs->count remains 0, the cleanup function free_overlay_changeset()
will skip its loop and fail to call of_node_put() for the previously
successfully resolved fragment nodes.

Could ovcs->count be updated to cnt before jumping to err_out so that
free_overlay_changeset() can clean up the previously populated elements?

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

  reply	other threads:[~2026-08-05 20:45 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
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 [this message]
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=20260805204513.806C41F000E9@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 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.