From: sashiko-bot@kernel.org
To: "Loic Poulain" <loic.poulain@oss.qualcomm.com>
Cc: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH v2 5/8] net: of_net: Add of_get_nvmem_eui48() helper for EUI-48 lookup
Date: Fri, 08 May 2026 18:20:25 +0000 [thread overview]
Message-ID: <20260508182026.22146C2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260507-block-as-nvmem-v2-5-bf17edd5134e@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] of_get_mac_address_nvmem() corrupts the output buffer on failure, causing network drivers to use invalid MAC addresses.
--
commit dfaa504d49a935a1aa8c630022d2ce8a6b303cce
Author: Loic Poulain <loic.poulain@oss.qualcomm.com>
net: of_net: Add of_get_nvmem_eui48() helper for EUI-48 lookup
Factor out the common NVMEM EUI-48 retrieval logic from
of_get_mac_address_nvmem() into a new of_get_nvmem_eui48() helper that
accepts the NVMEM cell name as a parameter.
> diff --git a/net/core/of_net.c b/net/core/of_net.c
> index 93ea425b9248a..79b289de0f16a 100644
> --- a/net/core/of_net.c
> +++ b/net/core/of_net.c
[ ... ]
> @@ -75,27 +72,53 @@ int of_get_mac_address_nvmem(struct device_node *np, u8 *addr)
> return ret;
> }
>
> - cell = of_nvmem_cell_get(np, "mac-address");
> + ret = of_get_nvmem_eui48(np, "mac-address", addr);
> + if (ret)
> + return ret;
> +
> + if (!is_valid_ether_addr(addr))
> + return -EINVAL;
Does this change inadvertently clobber the caller's output buffer when an
invalid MAC address is read?
Before this patch, of_get_mac_address_nvmem() only modified the output
buffer if the NVMEM-provided MAC address passed is_valid_ether_addr().
Now, it calls of_get_nvmem_eui48() which unconditionally copies any non-zero
6-byte value into the caller's buffer, and only then checks
is_valid_ether_addr(addr). If the MAC is invalid (e.g. multicast or
broadcast), it returns -EINVAL but leaves the invalid MAC in the caller's
buffer.
This can break existing callers that rely on the buffer remaining unmodified
on error. For example, in drivers/net/ethernet/freescale/enetc/enetc_pf_common.c,
enetc_setup_mac_address() initializes the buffer to zeroes, ignores non-defer
errors, and falls back to a hardware or random MAC if the buffer is still
all-zeroes. Because the buffer is clobbered with a non-zero invalid MAC,
the fallback is bypassed and enetc_set_si_hw_addr() programs the hardware
with the invalid MAC.
Similarly, in drivers/net/ethernet/renesas/sh_eth.c, read_mac_address()
checks if the buffer is non-zero to decide whether to read the MAC from
hardware registers. Clobbering the buffer causes the driver to skip the
valid hardware MAC and instead fall back to a random MAC.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260507-block-as-nvmem-v2-0-bf17edd5134e@oss.qualcomm.com?part=5
next prev parent reply other threads:[~2026-05-08 18:20 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-07 15:24 [PATCH v2 0/8] Support for block device NVMEM providers Loic Poulain
2026-05-07 15:24 ` [PATCH v2 1/8] dt-bindings: mmc: Document support for nvmem-layout Loic Poulain
2026-05-07 16:19 ` Support for block device NVMEM providers bluez.test.bot
2026-05-13 22:42 ` [PATCH v2 1/8] dt-bindings: mmc: Document support for nvmem-layout Rob Herring
2026-05-07 15:24 ` [PATCH v2 2/8] dt-bindings: net: wireless: qcom,ath10k: Add NVMEM MAC address cell Loic Poulain
2026-05-08 18:20 ` sashiko-bot
2026-05-07 15:24 ` [PATCH v2 3/8] dt-bindings: bluetooth: qcom: Add NVMEM BD " Loic Poulain
2026-05-07 15:24 ` [PATCH v2 4/8] block: implement NVMEM provider Loic Poulain
2026-05-08 18:20 ` sashiko-bot
2026-05-11 11:27 ` Bartosz Golaszewski
2026-05-07 15:24 ` [PATCH v2 5/8] net: of_net: Add of_get_nvmem_eui48() helper for EUI-48 lookup Loic Poulain
2026-05-08 18:20 ` sashiko-bot [this message]
2026-05-11 10:36 ` Bartosz Golaszewski
2026-05-07 15:24 ` [PATCH v2 6/8] Bluetooth: hci_sync: Add NVMEM-backed BD address retrieval Loic Poulain
2026-05-08 18:20 ` sashiko-bot
2026-05-07 15:24 ` [PATCH v2 7/8] Bluetooth: qca: Set NVMEM BD address quirks when address is invalid Loic Poulain
2026-05-11 11:29 ` Bartosz Golaszewski
2026-05-07 15:24 ` [PATCH v2 8/8] arm64: dts: qcom: arduino-imola: Describe NVMEM layout for WiFi/BT addresses Loic Poulain
2026-05-11 11:30 ` Bartosz Golaszewski
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=20260508182026.22146C2BCB0@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=loic.poulain@oss.qualcomm.com \
--cc=robh@kernel.org \
--cc=sashiko@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.