From: sashiko-bot@kernel.org
To: "Loic Poulain" <loic.poulain@oss.qualcomm.com>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v4 5/8] net: of_net: Add of_get_nvmem_eui48() helper for EUI-48 lookup
Date: Wed, 10 Jun 2026 07:53:49 +0000 [thread overview]
Message-ID: <20260610075350.163011F00898@smtp.kernel.org> (raw)
In-Reply-To: <20260609-block-as-nvmem-v4-5-45712e6b22c6@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The refactored `of_get_mac_address_nvmem()` allocates `u8 mac[ETH_ALEN]` on the stack without an explicit alignment attribute, but passes it to `is_valid_ether_addr()` and `ether_addr_copy()`, which explicitly require 2-byte alignment. Additionally, it replaces `memcpy()` with `ether_addr_copy()` for the output buffer `addr`, which places a new 16-bit alignment requirement on the caller-provided destination buffer. On architectures where `CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS` is disabled, passing unaligned buffers to these inline functions triggers hardware alignment faults (kernel panics).
--
commit bea465de4254300767e8f7bcd7c42eab2fe9f51f
Author: Loic Poulain <loic.poulain@oss.qualcomm.com>
net: of_net: Add of_get_nvmem_eui48() helper for EUI-48 lookup
This commit factors out the common NVMEM EUI-48 retrieval logic from
of_get_mac_address_nvmem() into a new of_get_nvmem_eui48() helper. It
updates of_get_mac_address_nvmem() to use this new function to preserve
the existing behavior while making the logic reusable.
> diff --git a/net/core/of_net.c b/net/core/of_net.c
> --- a/net/core/of_net.c
> +++ b/net/core/of_net.c
> @@ -61,9 +61,7 @@ static int of_get_mac_addr(struct device_node *np, const char *name, u8 *addr)
> int of_get_mac_address_nvmem(struct device_node *np, u8 *addr)
> {
> struct platform_device *pdev = of_find_device_by_node(np);
> - struct nvmem_cell *cell;
> - const void *mac;
> - size_t len;
> + u8 mac[ETH_ALEN];
[Severity: High]
Does this stack-allocated array need an explicit alignment attribute?
Because it is a u8 array, it only guarantees 1-byte alignment.
> int ret;
>
[ ... ]
> - mac = nvmem_cell_read(cell, &len);
> - nvmem_cell_put(cell);
>
> - if (IS_ERR(mac))
> - return PTR_ERR(mac);
> + ret = of_get_nvmem_eui48(np, "mac-address", mac);
> + if (ret)
> + return ret;
> +
> + if (!is_valid_ether_addr(mac))
[Severity: High]
Could this cause an alignment trap on architectures without efficient
unaligned access?
is_valid_ether_addr() expects its argument to be 2-byte aligned.
The previous implementation used the pointer returned by nvmem_cell_read(),
which was allocated via kzalloc() and naturally provided an 8-byte alignment
guarantee.
> + return -EINVAL;
> +
> + ether_addr_copy(addr, mac);
[Severity: High]
Can this ether_addr_copy() call cause an alignment fault?
ether_addr_copy() requires both the source and destination pointers to be
2-byte aligned. This replaces the safe memcpy() used in the previous
implementation and introduces a new 2-byte alignment requirement for the
caller-provided addr buffer, as well as the locally allocated mac array.
> + return 0;
> }
> EXPORT_SYMBOL(of_get_mac_address_nvmem);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260609-block-as-nvmem-v4-0-45712e6b22c6@oss.qualcomm.com?part=5
next prev parent reply other threads:[~2026-06-10 7:53 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-09 7:52 [PATCH v4 0/8] Support for block device NVMEM providers Loic Poulain
2026-06-09 7:52 ` [PATCH v4 1/8] dt-bindings: mmc: Document support for nvmem-layout Loic Poulain
2026-06-09 7:52 ` [PATCH v4 2/8] dt-bindings: net: wireless: qcom,ath10k: Document NVMEM cells Loic Poulain
2026-06-10 7:16 ` Krzysztof Kozlowski
2026-06-09 7:52 ` [PATCH v4 3/8] dt-bindings: bluetooth: qcom: Add NVMEM BD address cell Loic Poulain
2026-06-09 7:52 ` [PATCH v4 4/8] block: implement NVMEM provider Loic Poulain
2026-06-09 8:52 ` Bartosz Golaszewski
2026-06-09 10:13 ` Loic Poulain
2026-06-09 11:05 ` Bartosz Golaszewski
2026-06-10 7:53 ` sashiko-bot
2026-06-09 7:52 ` [PATCH v4 5/8] net: of_net: Add of_get_nvmem_eui48() helper for EUI-48 lookup Loic Poulain
2026-06-10 7:53 ` sashiko-bot [this message]
2026-06-09 7:52 ` [PATCH v4 6/8] Bluetooth: hci_sync: Add NVMEM-backed BD address retrieval Loic Poulain
2026-06-09 7:52 ` [PATCH v4 7/8] Bluetooth: qca: Set NVMEM BD address quirks when address is invalid Loic Poulain
2026-06-09 7:52 ` [PATCH v4 8/8] arm64: dts: qcom: arduino-imola: Describe NVMEM layout for WiFi/BT addresses Loic Poulain
2026-06-10 7:53 ` 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=20260610075350.163011F00898@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=loic.poulain@oss.qualcomm.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