From: sashiko-bot@kernel.org
To: "Yu-Chun Lin" <eleanor.lin@realtek.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH 2/3] soc: realtek: Add driver for DHC I/O level detector
Date: Thu, 04 Jun 2026 11:28:38 +0000 [thread overview]
Message-ID: <20260604112839.242251F00898@smtp.kernel.org> (raw)
In-Reply-To: <20260604111821.975624-3-eleanor.lin@realtek.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Ignored return values from regmap operations lead to uninitialized stack variable usage and potential hardware misconfiguration.
- [Low] Unnecessary dynamic memory allocation for probe-only data structure.
--
commit c604ce13442f04b606b3ba51b12003236c8a3ba6
Author: Tzuyi Chang <tychang@realtek.com>
soc: realtek: Add driver for DHC I/O level detector
Add driver support for the Realtek DHC I/O level detector. The driver reads
hardware registers to determine the current I/O voltage levels (e.g., 1.8V
or 3.3V) for specific IP blocks and configures pinctrl states.
> diff --git a/drivers/soc/realtek/rtd-io-detect.c b/drivers/soc/realtek/rtd-io-detect.c
> new file mode 100644
> index 0000000000000..84ef8ea23cb5c
> --- /dev/null
> +++ b/drivers/soc/realtek/rtd-io-detect.c
[ ... ]
> +static void detect_io_set(struct pinctrl *pinctrl,
> + const struct rtd_io_detect_desc_info *desc,
> + struct rtd_io_detect_data *data)
> +{
> + struct pinctrl_state *state_1v8;
> + struct pinctrl_state *state_3v3;
> + unsigned int val;
> + int ret;
[ ... ]
> + regmap_update_bits(data->base, desc->reg_offset,
> + BIT(desc->en_offset), BIT(desc->en_offset));
> +
> + regmap_read(data->base, desc->reg_offset, &val);
> +
> + ret = pinctrl_select_state(pinctrl,
> + (val & BIT(desc->status_offset)) ? state_3v3 : state_1v8);
[Severity: High]
If regmap_update_bits() or regmap_read() fail here, won't val remain
uninitialized?
Since val is used immediately after to select the voltage state, could this
cause the hardware to be misconfigured by applying 3.3V to a 1.8V pad if
it evaluates a garbage stack value?
> + if (ret)
> + dev_err(data->dev, "Failed to select pinctrl state\n");
> +}
> +
> +static int rtd_io_detect_probe(struct platform_device *pdev)
> +{
> + struct rtd_io_detect_data *data;
> + struct device *dev = &pdev->dev;
> + struct device_node *pinctrl_np;
> + struct pinctrl *pinctrl;
> + int i;
> +
> + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
> + if (!data)
> + return -ENOMEM;
[Severity: Low]
Does this structure need to be dynamically allocated and tied to the
device lifetime with devm_kzalloc()?
It looks like struct rtd_io_detect_data is only used locally within
rtd_io_detect_probe() to pass arguments into detect_io_set(). Since it is
never saved via platform_set_drvdata() or used in other callbacks, could it
just be allocated on the stack to save memory?
> +
> + pinctrl_np = of_parse_phandle(dev->of_node, "realtek,iso-pinctrl", 0);
> + if (!pinctrl_np) {
> + dev_err(dev, "Failed to find ISO pinctrl node\n");
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260604111821.975624-1-eleanor.lin@realtek.com?part=2
next prev parent reply other threads:[~2026-06-04 11:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-04 11:18 [PATCH 0/3] soc: realtek: Add Realtek DHC I/O level detector support Yu-Chun Lin
2026-06-04 11:18 ` [PATCH 1/3] dt-bindings: soc: realtek: Add Realtek DHC I/O level detector Yu-Chun Lin
2026-06-04 11:26 ` sashiko-bot
2026-06-04 12:49 ` Krzysztof Kozlowski
2026-06-04 11:18 ` [PATCH 2/3] soc: realtek: Add driver for " Yu-Chun Lin
2026-06-04 11:28 ` sashiko-bot [this message]
2026-06-04 11:18 ` [PATCH 3/3] arm64: dts: realtek: Add " Yu-Chun Lin
2026-06-04 11:33 ` sashiko-bot
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=20260604112839.242251F00898@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=eleanor.lin@realtek.com \
--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