From: sashiko-bot@kernel.org
To: "Abdurrahman Hussain" <abdurrahman@nexthop.ai>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v4 7/7] of: unittest: cover /aliases updates from overlay apply/revert
Date: Wed, 22 Jul 2026 07:35:06 +0000 [thread overview]
Message-ID: <20260722073507.2DE751F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260722-nh-of-alias-overlay-v4-7-fc96a40d2761@nexthop.ai>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but a guaranteed NULL pointer dereference occurs in the error handling path of `of_overlay_fdt_apply()` when `idr_alloc()` fails.
--
--- Patch [7]: [PATCH v4 7/7] of: unittest: cover /aliases updates from overlay apply/revert ---
commit 546dfcaa5ee21a92732ec54a5aca463b27b6686c
Author: Abdurrahman Hussain <abdurrahman@nexthop.ai>
of: unittest: cover /aliases updates from overlay apply/revert
Add overlay_alias.dtso plus of_unittest_overlay_alias() to cover the
"aliases inside an overlay" flow end-to-end. The runner applies the
overlay with a non-NULL target_base via of_overlay_fdt_apply() directly.
> diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
> index e255f54f4d760..2f5e4056efae0 100644
> --- a/drivers/of/unittest.c
> +++ b/drivers/of/unittest.c
[ ... ]
> @@ -3475,6 +3475,77 @@ static struct notifier_block of_nb = {
> .notifier_call = of_notify,
> };
>
> +/* created by cmd_wrap_S_dtbo in scripts/Makefile.dtbs */
> +extern uint8_t __dtbo_overlay_alias_begin[];
> +extern uint8_t __dtbo_overlay_alias_end[];
> +
> +static void __init of_unittest_overlay_alias(void)
> +{
[ ... ]
> + EXPECT_BEGIN(KERN_INFO,
> + "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /aliases/testcase-alias99");
> +
> + ret = of_overlay_fdt_apply(__dtbo_overlay_alias_begin, size,
> + &ovcs_id, base);
[Severity: High]
This is a pre-existing issue, but is there a guaranteed NULL pointer
dereference in the error handling path of of_overlay_fdt_apply() when
idr_alloc() fails?
If idr_alloc() fails (e.g., due to low memory), it returns a negative error
code (like -ENOMEM). This negative value is stored in ovcs->id, and the code
jumps to err_free_ovcs without initializing ovcs->ovcs_list:
drivers/of/overlay.c:of_overlay_fdt_apply() {
...
ovcs->id = idr_alloc(&ovcs_idr, ovcs, 1, 0, GFP_KERNEL);
if (ovcs->id <= 0) {
ret = ovcs->id;
goto err_free_ovcs;
}
...
}
In free_overlay_changeset(), the check `if (ovcs->id)` evaluates to true
because negative numbers are non-zero. It then calls
list_del(&ovcs->ovcs_list) on a zero-initialized list, dereferencing
NULL->next:
drivers/of/overlay.c:free_overlay_changeset() {
...
if (ovcs->id) {
idr_remove(&ovcs_idr, ovcs->id);
list_del(&ovcs->ovcs_list);
ovcs->id = 0;
}
...
}
Could this memory allocation failure under load cause a kernel panic during an
overlay apply attempt?
> +
> + EXPECT_END(KERN_INFO,
> + "OF: overlay: WARNING: memory leak will occur if overlay removed, property: /aliases/testcase-alias99");
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260722-nh-of-alias-overlay-v4-0-fc96a40d2761@nexthop.ai?part=7
prev parent reply other threads:[~2026-07-22 7:35 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 7:14 [PATCH v4 0/7] of: teach overlay code to keep /aliases in sync Abdurrahman Hussain
2026-07-22 7:14 ` [PATCH v4 1/7] of: resolve alias-prefixed paths under devtree_lock Abdurrahman Hussain
2026-07-22 7:14 ` [PATCH v4 2/7] of: incrementally update /aliases lookup on reconfig notifications Abdurrahman Hussain
2026-07-22 7:14 ` [PATCH v4 3/7] of/overlay: look up absolute target-paths absolutely Abdurrahman Hussain
2026-07-22 7:25 ` sashiko-bot
2026-07-22 7:14 ` [PATCH v4 4/7] of/overlay: put property on deadprops only after changeset add succeeds Abdurrahman Hussain
2026-07-22 7:14 ` [PATCH v4 5/7] of/overlay: return ERR_PTR from dup_and_fixup_symbol_prop() Abdurrahman Hussain
2026-07-22 7:24 ` sashiko-bot
2026-07-22 7:14 ` [PATCH v4 6/7] of/overlay: rewrite /aliases path values to live-tree paths Abdurrahman Hussain
2026-07-22 7:14 ` [PATCH v4 7/7] of: unittest: cover /aliases updates from overlay apply/revert Abdurrahman Hussain
2026-07-22 7:35 ` sashiko-bot [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=20260722073507.2DE751F00A3A@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