From: Chih Kai Hsu <hsu.chih.kai@realtek.com>
To: "netdev-bot+sashiko@kernel.org" <netdev-bot+sashiko@kernel.org>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
"kuba@kernel.org" <kuba@kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
nic_swsd <nic_swsd@realtek.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"edumazet@google.com" <edumazet@google.com>,
"bjorn@mork.no" <bjorn@mork.no>,
"pabeni@redhat.com" <pabeni@redhat.com>,
"andrew+netdev@lunn.ch" <andrew+netdev@lunn.ch>
Subject: RE: [PATCH net-next v5 2/9] r8152: split RTL_VER_17 into QFN68 and QFN100 package variants
Date: Tue, 6 Oct 2026 09:23:07 +0000 [thread overview]
Message-ID: <b3471b4acf7047169eb92258d710e6f5@realtek.com> (raw)
In-Reply-To: <179119424050.434549.6174729043039044928@kernel.org>
> Thank you for your contribution! Sashiko AI review found 2 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 2 (1) · Low: 0
>
> If you believe none of the issues are legitimate, please reply to each issue of
> Medium severity or higher and explain why the AI is wrong.
> If any of them are legitimate and you plan to respin, please let patchwork know
> by including "pw-bot: cr" as a separate line at the end of your reply (one such
> reply per series is enough).
>
> - [Medium] The commit message says the split is needed because QFN68 and
> QFN100 "need different firmware and a package-specific u2phy backup-…
> - [Medium] In __rtl_get_pkg_det() (drivers/net/usb/r8152.c), the retry
> loop `for (i = 0, ret = 0; i < 3 && ret != 4; i++) ret =…
>
> Pre-existing issues:
> - [Medium] This problem wasn't introduced by this patch, but in
> __rtl_get_hw_ver() (drivers/net/usb/r8152.c) the buffer `tmp` is…
>
> --
>
> r8152: split RTL_VER_17 into QFN68 and QFN100 package variants
>
> This commit splits RTL_VER_17 into RTL_VER_17_QFN68 and
> RTL_VER_17_QFN100.
> The package is detected by a new __rtl_get_pkg_det() helper that reads
> PLA_PKG_DET. Every RTL_VER_17 switch case now handles both variants, and
> r8159_init() gains a u2phy backup restore write that only applies to QFN68.
>
> > diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index
> > 4d8f0815d79d1..30af6ed3a638f 100644
> > --- a/drivers/net/usb/r8152.c
> > +++ b/drivers/net/usb/r8152.c
>
> [ ... ]
>
> > @@ -10172,7 +10194,8 @@ static int rtl_fw_init(struct r8152 *tp)
> > case RTL_VER_16:
> > rtl_fw->fw_name = FIRMWARE_8157_1;
> > break;
> > - case RTL_VER_17:
> > + case RTL_VER_17_QFN68:
> > + case RTL_VER_17_QFN100:
> > rtl_fw->fw_name = FIRMWARE_8159_1;
>
> [Severity: Medium]
> The commit message says the two packages "need different firmware and a
> package-specific u2phy backup-restore patch". However, rtl_fw_init() still gives
> both RTL_VER_17_QFN68 and RTL_VER_17_QFN100 the same firmware,
> FIRMWARE_8159_1 ("rtl_nic/rtl8159-1.fw").
>
> The driver still has only one 8159 firmware define and one
> MODULE_FIRMWARE(FIRMWARE_8159_1). The later patches in the series, up
> to
> "r8152: enable UPS for RTL8157 and RTL8159 QFN68", do not change this
> either.
>
> Is per-package firmware selection missing from this patch? Or should the
> commit message drop the claim about different firmware?
I will reword the commit message to drop the claim.
>
> > break;
> > default:
> > @@ -10182,9 +10205,38 @@ static int rtl_fw_init(struct r8152 *tp)
> > return 0;
> > }
> >
> > +static u32 __rtl_get_pkg_det(struct usb_device *udev) {
> > + u32 pkg_det = 0;
> > + __le32 *tmp;
> > + int ret, i;
> > +
> > + tmp = kmalloc_obj(*tmp);
> > + if (!tmp)
> > + return 0;
> > +
> > + for (i = 0, ret = 0; i < 3 && ret != 4; i++)
> > + ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
> > + RTL8152_REQ_GET_REGS,
> RTL8152_REQT_READ,
> > + PLA_PKG_DET, MCU_TYPE_PLA,
> tmp,
> > + sizeof(*tmp),
> > + USB_CTRL_GET_TIMEOUT);
> > +
> > + if (ret == sizeof(*tmp)) {
> > + if (i != 0)
> > + dev_warn(&udev->dev,
> > + "Needed %d retries to read
> package\n",
> > + i);
>
> [Severity: Medium]
> Won't this warning fire on every successful read? The loop increments i after
> the iteration that succeeds. If the first usb_control_msg() returns 4, i is already
> 1 when the loop exits, so the i != 0 check is always true.
Actually, I will fix it.
>
> The printed count is also one too high: 1 for a first-try success, 3 for a success
> on the third attempt.
>
> The version read loop in __rtl_get_hw_ver() avoids this by breaking out on
> success:
>
> for (i = 0; i < 3; i++) {
> ret = usb_control_msg(...);
> if (ret > 0) {
> ocp_data = (__le32_to_cpu(*tmp) >> 16) &
> VERSION_MASK;
> break;
> }
> }
>
> if (i != 0 && ret > 0)
> dev_warn(&udev->dev, "Needed %d retries to read
> version\n", i);
>
> __rtl_get_hw_ver() runs from both the cfgselector and the probe paths, so the
> false warning can appear more than once per RTL8159 plug-in. The code is still
> the same at the end of the series.
>
> > +
> > + pkg_det = __le32_to_cpu(*tmp) & PKG_MASK;
> > + }
> > +
> > + kfree(tmp);
> > + return pkg_det;
> > +}
> > +
> > static u8 __rtl_get_hw_ver(struct usb_device *udev) {
> > u32 ocp_data = 0;
> > + u32 pkg_det = 0;
> > __le32 *tmp;
> > u8 version;
> > int ret;
>
> [Severity: Medium]
> This isn't a bug introduced by this patch, but the PLA_TCR0 read in
> __rtl_get_hw_ver() accepts a reply of any positive length:
>
> tmp = kmalloc_obj(*tmp);
> ...
> if (ret > 0) {
> ocp_data = (__le32_to_cpu(*tmp) >> 16) &
> VERSION_MASK;
> break;
> }
>
> kmalloc_obj() does not zero the buffer. If a faulty or malicious device sends
> only 1 to 3 bytes, can the upper bytes of *tmp still hold leftover heap data that
> then gets decoded as the chip version?
>
> That could misidentify the chip, or leak uninitialized heap bytes to dmesg
> through the "Unknown version 0x%04x" message.
>
> The new __rtl_get_pkg_det() helper already requires ret == sizeof(*tmp).
> Would the same check make sense here?
>
> [ ... ]
>
> --
> Sashiko AI review ·
> https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261001091144.28191-1
> -nic_swsd%40realtek.com
Best Regards,
Chih-Kai
---
pw-bot: cr
next prev parent reply other threads:[~2026-10-06 9:23 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-01 9:11 [PATCH net-next v5 0/9] r8152: refactor and extend RTL8157/8159 support Chih Kai Hsu
2026-10-01 9:11 ` [PATCH net-next v5 1/9] r8152: split r8156_init per chip and add missing init writes Chih Kai Hsu
2026-10-05 9:57 ` netdev-bot+sashiko
2026-10-06 9:18 ` Chih Kai Hsu
2026-10-01 9:11 ` [PATCH net-next v5 2/9] r8152: split RTL_VER_17 into QFN68 and QFN100 package variants Chih Kai Hsu
2026-10-05 9:57 ` netdev-bot+sashiko
2026-10-06 9:23 ` Chih Kai Hsu [this message]
2026-10-01 9:11 ` [PATCH net-next v5 3/9] r8152: split rtl8156_enable/up/down into per-chip-family functions Chih Kai Hsu
2026-10-01 9:11 ` [PATCH net-next v5 4/9] r8152: fix up and down register settings for RTL8156/8156B/8157/8159 Chih Kai Hsu
2026-10-01 9:11 ` [PATCH net-next v5 5/9] r8152: split r8157_hw_phy_cfg into RTL8157 and RTL8159 variants Chih Kai Hsu
2026-10-05 9:57 ` netdev-bot+sashiko
2026-10-06 9:24 ` Chih Kai Hsu
2026-10-01 9:11 ` [PATCH net-next v5 6/9] r8152: add rtl8157_unload and rtl8157_change_mtu Chih Kai Hsu
2026-10-05 9:57 ` netdev-bot+sashiko
2026-10-01 9:11 ` [PATCH net-next v5 7/9] r8152: add TGPHY register access for RTL8157 and RTL8159 Chih Kai Hsu
2026-10-05 9:57 ` netdev-bot+sashiko
2026-10-06 9:41 ` Chih Kai Hsu
2026-10-01 9:11 ` [PATCH net-next v5 8/9] r8152: extract rtl_fc_pause_pkt_en() and apply it to RTL8156/8157/8159 Chih Kai Hsu
2026-10-05 9:57 ` netdev-bot+sashiko
2026-10-01 9:11 ` [PATCH net-next v5 9/9] r8152: enable UPS for RTL8157 and RTL8159 QFN68 Chih Kai Hsu
2026-10-05 9:57 ` netdev-bot+sashiko
2026-10-06 9:43 ` Chih Kai Hsu
2026-10-01 9:13 ` [PATCH net-next v5 0/9] r8152: refactor and extend RTL8157/8159 support netdev-bot+sinfo
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=b3471b4acf7047169eb92258d710e6f5@realtek.com \
--to=hsu.chih.kai@realtek.com \
--cc=andrew+netdev@lunn.ch \
--cc=bjorn@mork.no \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=netdev-bot+sashiko@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nic_swsd@realtek.com \
--cc=pabeni@redhat.com \
/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.