Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Aleksei Sviridkin" <f@lex.la>
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org
Subject: Re: [RFC PATCH net-next 6/9] net: mdio: add Airoha EN8811H MDIO device driver
Date: Sun, 30 Aug 2026 05:26:22 +0000	[thread overview]
Message-ID: <20260830052622.7637A1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260829052546.1152446-7-f@lex.la>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [Medium] The driver lacks PM suspend/resume callbacks to recover the volatile firmware state after a power cycle during system suspend.

Pre-existing issues:
- [High] The firmware download loop in `__air_write_buf` assumes the firmware size is a multiple of 4, causing an out-of-bounds read if it is not.
--

commit 03babf30d531494d26f97bc52b83619b8709ea53
Author: Aleksei Sviridkin <f@lex.la>

net: mdio: add Airoha EN8811H MDIO device driver

This commit introduces an MDIO device driver for the Airoha EN8811H.
It manages the chip as an MD32 microcontroller in bootloader mode,
polling for firmware files and downloading them once available before
it becomes an Ethernet PHY.

> diff --git a/drivers/net/mdio/mdio-airoha-en8811h.c b/drivers/net/mdio/mdio-airoha-en8811h.c
> new file mode 100644
> index 0000000000000..e16211da3d705
> --- /dev/null
> +++ b/drivers/net/mdio/mdio-airoha-en8811h.c

[ ... ]

> +static void en8811h_mcu_fw_poll(struct work_struct *work)
> +{
> +	struct en8811h_mcu *mcu = container_of(to_delayed_work(work),
> +					       struct en8811h_mcu, fw_poll);
> +	struct device *dev = &mcu->mdiodev->dev;
> +	int ret;
> +
> +	/* The chip enumerates as a C22 PHY; MMD access is indirect */
> +	ret = air_en8811h_fw_download(mcu->mdiodev->bus, mcu->mdiodev->addr,
> +				      false, dev, &mcu->fw_version);

[Severity: High]
This is a pre-existing issue, but does the firmware download loop in
__air_write_buf() (called via air_en8811h_fw_download()) have a bounds
checking issue if the firmware size is not a multiple of 4?

Looking at drivers/net/phy/air_phy_lib.c:__air_write_buf():

	for (offset = 0; offset < fw->size; offset += 4) {
		val = get_unaligned_le16(&fw->data[offset + 2]);
		ret = __mdiobus_write(bus, addr, AIR_BPBUS_WR_DATA_HIGH, val);
		if (ret < 0)
			return ret;

		val = get_unaligned_le16(&fw->data[offset]);
		ret = __mdiobus_write(bus, addr, AIR_BPBUS_WR_DATA_LOW, val);
		if (ret < 0)
			return ret;
	}

The loop blindly advances by 4 and reads at offset + 2 and offset without
verifying the remaining buffer size. A malformed or truncated firmware file
could cause an out-of-bounds read and potentially lead to a kernel crash.

> +	if (!ret) {
> +		dev_dbg(dev, "firmware %08x running after %ums\n",
> +			mcu->fw_version, mcu->waited_ms);
> +		return;
> +	}

[ ... ]

> +static const struct of_device_id en8811h_mcu_of_match[] = {
> +	{ .compatible = "airoha,en8811h-mcu" },
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(of, en8811h_mcu_of_match);
> +
> +static struct mdio_driver en8811h_mcu_driver = {
> +	.probe = en8811h_mcu_probe,
> +	.remove = en8811h_mcu_remove,
> +	.mdiodrv.driver = {
> +		.name = "airoha-en8811h-mcu",
> +		.of_match_table = en8811h_mcu_of_match,
> +	},
> +};

[Severity: Medium]
Will this device permanently fail to initialize after system suspend if power
to the MD32 chip is cut?

If the hardware platform removes power to the MD32 chip during system suspend,
its volatile RAM will be wiped, returning the chip to bootloader mode. Because
the driver lacks PM suspend and resume callbacks to re-download the firmware
upon waking, the device will remain in the bootloader state and fail
subsequent PHY communication.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260829052546.1152446-1-f@lex.la?part=6

  reply	other threads:[~2026-08-30  5:26 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-29  5:25 [RFC PATCH net-next 0/9] net: survive a PHY whose firmware arrives after the MAC probes Aleksei Sviridkin
2026-08-29  5:25 ` [RFC PATCH net-next 1/9] dt-bindings: net: add Airoha EN8811H PHY MCU Aleksei Sviridkin
2026-08-29  5:25 ` [RFC PATCH net-next 2/9] dt-bindings: net: ethernet-controller: add slow-to-probe Aleksei Sviridkin
2026-08-30  5:26   ` sashiko-bot
2026-09-04  0:29   ` Andrew Lunn
2026-08-29  5:25 ` [RFC PATCH net-next 3/9] net: phy: air: type the buckpbus core on the bus and address Aleksei Sviridkin
2026-09-04  0:48   ` Andrew Lunn
2026-08-29  5:25 ` [RFC PATCH net-next 4/9] net: phy: air: move the EN8811H firmware download into the library Aleksei Sviridkin
2026-09-04  1:16   ` Andrew Lunn
2026-08-29  5:25 ` [RFC PATCH net-next 5/9] net: phy: air: skip the download when the MD32 is already running Aleksei Sviridkin
2026-08-29  5:25 ` [RFC PATCH net-next 6/9] net: mdio: add Airoha EN8811H MDIO device driver Aleksei Sviridkin
2026-08-30  5:26   ` sashiko-bot [this message]
2026-09-04  1:36   ` Andrew Lunn
2026-08-29  5:25 ` [RFC PATCH net-next 7/9] net: mdio: en8811h: add the nested pass-through bus Aleksei Sviridkin
2026-09-04  1:43   ` Andrew Lunn
2026-08-29  5:25 ` [RFC PATCH net-next 8/9] net: phylink: wait for PHYs that are known to probe late Aleksei Sviridkin
2026-08-30  5:26   ` sashiko-bot
2026-08-29  5:25 ` [RFC PATCH net-next 9/9] net: phylink: report no link modes while a late PHY is missing Aleksei Sviridkin
2026-08-30  5:26   ` 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=20260830052622.7637A1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=f@lex.la \
    --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