From: sashiko-bot@kernel.org
To: "Abdurrahman Hussain" <abdurrahman@nexthop.ai>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v4 4/6] of/overlay: return ERR_PTR from dup_and_fixup_symbol_prop()
Date: Wed, 22 Jul 2026 01:13:18 +0000 [thread overview]
Message-ID: <20260722011319.18CDA1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260721-nh-of-alias-overlay-v4-4-8ad097e31e36@nexthop.ai>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Double-free and use-after-free of `new_prop` on the `of_changeset_add_property()` error path.
--
--- Patch [4]: [PATCH v4 4/6] of/overlay: return ERR_PTR from dup_and_fixup_symbol_prop() ---
commit c4400996264f78e84238a0b8d2c87f7489c72180
Author: Abdurrahman Hussain <abdurrahman@nexthop.ai>
of/overlay: return ERR_PTR from dup_and_fixup_symbol_prop()
dup_and_fixup_symbol_prop() previously returned NULL for malformed input,
unresolved paths, and allocation failures, which the caller collapsed into
-ENOMEM. This patch changes the function to return an ERR_PTR instead.
The caller is updated to propagate the specific errno.
> diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c
> index 74aea704835ac..ad4e504825157 100644
> --- a/drivers/of/overlay.c
> +++ b/drivers/of/overlay.c
[ ... ]
> @@ -350,6 +354,8 @@ static int add_changeset_property(struct overlay_changeset *ovcs,
> if (prop)
> return -EINVAL;
> new_prop = dup_and_fixup_symbol_prop(ovcs, overlay_prop);
> + if (IS_ERR(new_prop))
> + return PTR_ERR(new_prop);
> } else {
> new_prop = __of_prop_dup(overlay_prop, GFP_KERNEL);
> }
[Severity: High]
This is a pre-existing issue, but could this code path lead to a double-free
on the error path for add_changeset_property()?
Looking further down in add_changeset_property(), if we are not in a livetree,
new_prop is linked into the deadprops list:
if (!prop) {
if (!target->in_livetree) {
new_prop->next = target->np->deadprops;
target->np->deadprops = new_prop;
}
ret = of_changeset_add_property(&ovcs->cset, target->np,
new_prop);
If of_changeset_add_property() fails (for example, due to memory exhaustion),
ret is non-zero, and the function frees new_prop at the bottom:
if (ret)
__of_prop_free(new_prop);
Does this leave the freed new_prop still attached to target->np->deadprops?
When the overlay application aborts and the unattached dynamically allocated
device node is cleaned up via of_node_release(), it iterates over the
deadprops list and calls __of_prop_free() on each property again. Can this
result in a use-after-free and double-free of the property?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260721-nh-of-alias-overlay-v4-0-8ad097e31e36@nexthop.ai?part=4
next prev parent reply other threads:[~2026-07-22 1:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 1:01 [PATCH v4 0/6] of: teach overlay code to keep /aliases in sync Abdurrahman Hussain
2026-07-22 1:01 ` [PATCH v4 1/6] of: resolve alias-prefixed paths under devtree_lock Abdurrahman Hussain
2026-07-22 1:19 ` sashiko-bot
2026-07-22 7:30 ` Krzysztof Kozlowski
2026-07-22 1:01 ` [PATCH v4 2/6] of: incrementally update /aliases lookup on reconfig notifications Abdurrahman Hussain
2026-07-22 7:35 ` Krzysztof Kozlowski
2026-07-22 1:01 ` [PATCH v4 3/6] of/overlay: look up absolute target-paths absolutely Abdurrahman Hussain
2026-07-22 1:01 ` [PATCH v4 4/6] of/overlay: return ERR_PTR from dup_and_fixup_symbol_prop() Abdurrahman Hussain
2026-07-22 1:13 ` sashiko-bot [this message]
2026-07-22 7:36 ` Krzysztof Kozlowski
2026-07-22 1:01 ` [PATCH v4 5/6] of/overlay: rewrite /aliases path values to live-tree paths Abdurrahman Hussain
2026-07-22 1:16 ` sashiko-bot
2026-07-22 1:01 ` [PATCH v4 6/6] 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=20260722011319.18CDA1F000E9@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.