From: sashiko-bot@kernel.org
To: "Roman Vivchar" <rva333@protonmail.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH RESEND v5 3/4] nvmem: mtk-efuse: add CPU speedbin post-processing
Date: Tue, 17 Nov 2026 11:56:11 +0000 [thread overview]
Message-ID: <sashiko-outbox-218743@kernel.org> (raw)
In-Reply-To: <20261117-6572-nvmem-v5-3-9b561a8a83e1@protonmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] nvmem: mtk-efuse: prefix false match in
mtk_efuse_fixup_dt_cell_info()
--
commit c5f5a828d690918eacfadf756d8f32a95a9237dd
Author: Roman Vivchar <rva333@protonmail.com>
nvmem: mtk-efuse: add CPU speedbin post-processing
This commit adds a post-processing callback for "cpu-speedbin" nvmem cells to
convert numeric CPU speedbin values into bitmasks for opp-supported-hw.
> diff --git a/drivers/nvmem/mtk-efuse.c b/drivers/nvmem/mtk-efuse.c
> index 980c29d013375..d2e5c69c580e3 100644
> --- a/drivers/nvmem/mtk-efuse.c
> +++ b/drivers/nvmem/mtk-efuse.c
> @@ -70,6 +70,18 @@ static int mtk_efuse_gpu_speedbin_pp(void *context, const char *id, int index,
> return 0;
> }
>
> +static int mtk_efuse_cpu_speedbin_pp(void *context, const char *id, int index,
> + unsigned int offset, void *data, size_t bytes)
> +{
> + u8 *val = data;
> +
> + if (val[0] >= 8)
> + return -EINVAL;
> +
> + val[0] = BIT(val[0]);
> + return 0;
> +}
> +
> static void mtk_efuse_fixup_dt_cell_info(struct nvmem_device *nvmem,
> struct nvmem_cell_info *cell)
> {
> @@ -83,6 +95,13 @@ static void mtk_efuse_fixup_dt_cell_info(struct nvmem_device *nvmem,
> if (cell->nbits <= 3 &&
> strncmp(cell->name, "gpu-speedbin", min(sz, strlen("gpu-speedbin"))) == 0)
> cell->read_post_process = mtk_efuse_gpu_speedbin_pp;
> +
> + /*
> + * On mobile SoCs, the CPU speedbin is a number. Convert it to
> + * a bitmask for supported-hw usage.
> + */
> + if (strncmp(cell->name, "cpu-speedbin", min(sz, strlen("cpu-speedbin"))) == 0)
> + cell->read_post_process = mtk_efuse_cpu_speedbin_pp;
> }
[Severity: Medium]
Can this strncmp() check match unrelated cells whose name is a shorter
prefix of "cpu-speedbin"?
Because sz is strlen(cell->name), min(sz, strlen("cpu-speedbin")) evaluates
to sz whenever cell->name is shorter than "cpu-speedbin", and unlike the
"gpu-speedbin" check above, cell->nbits is not checked. Any shorter prefix
such as "cpu" will get mtk_efuse_cpu_speedbin_pp() attached, causing reads
of that cell to fail with -EINVAL or have their first byte overwritten with
BIT(val[0]). Using strcmp(cell->name, "cpu-speedbin") == 0 or
strncmp(cell->name, "cpu-speedbin", strlen("cpu-speedbin")) == 0 would avoid
matching shorter prefixes.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117-6572-nvmem-v5-0-9b561a8a83e1@protonmail.com?part=3
next prev parent reply other threads:[~2026-11-17 11:56 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 11:33 [PATCH RESEND v5 0/4] nvmem: mtk-efuse: mt6572 support Roman Vivchar via B4 Relay
2026-11-17 11:33 ` Roman Vivchar
2026-11-17 11:33 ` [PATCH RESEND v5 1/4] dt-bindings: nvmem: mediatek: efuse: add mt6572 Roman Vivchar via B4 Relay
2026-11-17 11:33 ` Roman Vivchar
2026-11-17 11:33 ` [PATCH RESEND v5 2/4] nvmem: mtk-efuse: add support for 32-bit aligned reads Roman Vivchar via B4 Relay
2026-11-17 11:33 ` Roman Vivchar
2026-11-17 11:33 ` [PATCH RESEND v5 3/4] nvmem: mtk-efuse: add CPU speedbin post-processing Roman Vivchar via B4 Relay
2026-11-17 11:33 ` Roman Vivchar
2026-11-17 11:56 ` sashiko-bot [this message]
2026-11-17 11:56 ` AngeloGioacchino Del Regno
2026-11-17 12:02 ` Roman Vivchar
2026-11-17 12:08 ` AngeloGioacchino Del Regno
2026-11-17 12:16 ` Roman Vivchar
2026-11-17 11:33 ` [PATCH RESEND v5 4/4] nvmem: mtk-efuse: add mt6572 support Roman Vivchar via B4 Relay
2026-11-17 11:33 ` Roman Vivchar
2026-11-17 11:56 ` AngeloGioacchino Del Regno
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=sashiko-outbox-218743@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=rva333@protonmail.com \
--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.