From: sashiko-bot@kernel.org
To: "Alexey Charkov" <alchark@flipper.net>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH 3/4] nvmem: layouts: Add Rockchip OTP CPUID layout driver
Date: Tue, 01 Sep 2026 16:03:39 +0000 [thread overview]
Message-ID: <20260901160339.C57051F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260901-rk3576-otp-cpuid-mac-v1-3-ea9135270fc2@flipper.net>
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 module unload leaves a dangling function pointer in the nvmem core, leading to execution of unmapped memory when the cell is read.
--
commit eb43a3b0551c59093ae8bd5ad7028542c1ba58bd
Author: Alexey Charkov <alchark@flipper.net>
nvmem: layouts: Add Rockchip OTP CPUID layout driver
Rockchip SoCs customarily use the CPU ID programmed into their on-chip OTP
memory to derive stable Ethernet MAC addresses even when a board doesn't
otherwise have dedicated storage for those.
Reproduce the same derivation in the kernel and expose the result as an
nvmem cell named "mac-address", so that of_get_mac_address() picks it up
through its standard nvmem fallback.
> diff --git a/drivers/nvmem/layouts/rockchip-otp-cpuid.c b/drivers/nvmem/layouts/rockchip-otp-cpuid.c
> new file mode 100644
> index 0000000000000..61f509c4a8cf2
> --- /dev/null
> +++ b/drivers/nvmem/layouts/rockchip-otp-cpuid.c
[ ... ]
> @@ -62,15 +62,15 @@ static int rockchip_cpuid_add_cells(struct nvmem_layout *layout)
>
> info.name = "mac-address";
> info.offset = data->offset;
> info.raw_len = ROCKCHIP_CPUID_LEN;
> info.bytes = ETH_ALEN;
> info.read_post_process = rockchip_cpuid_mac_pp;
> info.np = of_get_child_by_name(layout_np, info.name);
>
> of_node_put(layout_np);
>
> ret = nvmem_add_one_cell(layout->nvmem, &info);
> if (ret)
> of_node_put(info.np);
>
> return ret;
> }
[ ... ]
> static void rockchip_cpuid_remove(struct nvmem_layout *layout)
> {
> nvmem_layout_unregister(layout);
> }
[Severity: High]
This isn't a bug introduced by this patch, but does unloading this module leave
a dangling function pointer in the nvmem core?
In rockchip_cpuid_add_cells() in drivers/nvmem/layouts/rockchip-otp-cpuid.c,
the module's function pointer is handed over to the core cell structure:
info.read_post_process = rockchip_cpuid_mac_pp;
ret = nvmem_add_one_cell(layout->nvmem, &info);
When the module is unloaded, rockchip_cpuid_remove() calls
nvmem_layout_unregister(), but that function is an empty stub in the nvmem
framework. As a result, it silently fails to remove the dynamically allocated
cells.
Because the cell outlives the module without a module reference protecting
the layout driver, a subsequent read of the cell (e.g., via sysfs) will
invoke the freed rockchip_cpuid_mac_pp() callback.
Could this lead to execution of unmapped memory and a kernel panic?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260901-rk3576-otp-cpuid-mac-v1-0-ea9135270fc2@flipper.net?part=3
next prev parent reply other threads:[~2026-09-01 16:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 15:33 [PATCH 0/4] nvmem: Derive Rockchip MAC addresses from the OTP CPU ID Alexey Charkov
2026-09-01 15:33 ` [PATCH 1/4] nvmem: rockchip-otp: Serialize reads Alexey Charkov
2026-09-01 15:39 ` sashiko-bot
2026-09-02 9:10 ` Miquel Raynal
2026-09-02 9:24 ` Alexey Charkov
2026-09-02 10:17 ` Miquel Raynal
2026-09-02 12:40 ` Alexey Charkov
2026-09-03 8:06 ` Miquel Raynal
2026-09-01 15:33 ` [PATCH 2/4] dt-bindings: nvmem: layouts: Add Rockchip OTP CPUID layout Alexey Charkov
2026-09-01 15:33 ` [PATCH 3/4] nvmem: layouts: Add Rockchip OTP CPUID layout driver Alexey Charkov
2026-09-01 16:03 ` sashiko-bot [this message]
2026-09-02 9:40 ` Miquel Raynal
2026-09-01 15:33 ` [PATCH 4/4] arm64: dts: rockchip: Derive GMAC MAC addresses from OTP on RK3576 Alexey Charkov
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=20260901160339.C57051F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alchark@flipper.net \
--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;
as well as URLs for NNTP newsgroup(s).