From: sashiko-bot@kernel.org
To: "Joey Lu" <a0987203069@gmail.com>
Cc: devicetree@vger.kernel.org, neil.armstrong@linaro.org,
conor+dt@kernel.org, olteanv@gmail.com, vkoul@kernel.org,
linux-phy@lists.infradead.org, robh@kernel.org
Subject: Re: [PATCH v5 3/3] phy: nuvoton: phy-ma35d1-usb2: extend to dual-port with OTG support
Date: Mon, 14 Sep 2026 03:27:13 +0000 [thread overview]
Message-ID: <20260914032713.9434D1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260914031859.385224-4-a0987203069@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Unchecked regmap_read return value in ma35_role_sw_get leads to the use of uninitialized stack memory, potentially leaking 1 bit of kernel stack data to userspace.
--
commit 93b1ad8e66488910d7c296427cb3acbec813e0a2
Author: Joey Lu <a0987203069@gmail.com>
phy: nuvoton: phy-ma35d1-usb2: extend to dual-port with OTG support
This patch extends the Nuvoton MA35D1 USB 2.0 PHY driver to manage both PHY0
and PHY1 ports using a unified init callback. It updates the reset and clock
polling sequences and adds a read-only USB role switch for PHY0 to expose
the active role to userspace.
> diff --git a/drivers/phy/nuvoton/phy-ma35d1-usb2.c b/drivers/phy/nuvoton/phy-ma35d1-usb2.c
> index 9a459b700ed48..2c60be0ee50f7 100644
> --- a/drivers/phy/nuvoton/phy-ma35d1-usb2.c
> +++ b/drivers/phy/nuvoton/phy-ma35d1-usb2.c
[ ... ]
> +static enum usb_role ma35_role_sw_get(struct usb_role_switch *sw)
> +{
> + struct ma35_usb_phy *p = usb_role_switch_get_drvdata(sw);
> + u32 val;
> +
> + regmap_read(p->sysreg, MA35_SYS_PWRONOTP, &val);
> +
> + return (val & PWRONOTP_USBP0ID) ? USB_ROLE_HOST : USB_ROLE_DEVICE;
> +}
[Severity: Medium]
Could this lead to the use of uninitialized stack memory? If the call to
regmap_read() fails, the variable val will remain uninitialized. When
evaluated in the return statement, it would return a USB role based on stack
garbage.
Since this role is exposed to userspace via the sysfs role switch interface,
could this potentially leak one bit of kernel stack information to userspace
if the MMIO read happens to fail? Should the return value of regmap_read()
be checked before evaluating val?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260914031859.385224-1-a0987203069@gmail.com?part=3
prev parent reply other threads:[~2026-09-14 3:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 3:18 [PATCH v5 0/3] phy: nuvoton: extend MA35D1 USB2 PHY driver for dual-port OTG support Joey Lu
2026-09-14 3:18 ` [PATCH v5 1/3] dt-bindings: phy: nuvoton,ma35d1-usb2-phy: extend for dual-port and OTG Joey Lu
2026-09-14 3:18 ` [PATCH v5 2/3] arm64: dts: nuvoton: ma35d1: add USB controllers and dual-port PHY node Joey Lu
2026-09-19 5:49 ` Jacky Huang
2026-09-24 6:48 ` Joey Lu
2026-09-14 3:18 ` [PATCH v5 3/3] phy: nuvoton: phy-ma35d1-usb2: extend to dual-port with OTG support Joey Lu
2026-09-14 3:27 ` 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=20260914032713.9434D1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=a0987203069@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=neil.armstrong@linaro.org \
--cc=olteanv@gmail.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vkoul@kernel.org \
/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