From: Srinivas Kandagatla <srini@kernel.org>
To: "Michael C. Pratt" <mcpratt@pm.me>, linux-kernel@vger.kernel.org
Cc: "Rafał Miłecki" <rafal@milecki.pl>,
"Christian Marangi" <ansuelsmth@gmail.com>,
"Srinivas Kandagatla" <srini@kernel.org>
Subject: Re: [PATCH] nvmem: layouts: u-boot-env: handle quotes in MAC post process
Date: Sun, 20 Sep 2026 17:44:49 +0100 [thread overview]
Message-ID: <5a153e76-a149-4084-92cb-785f7b47c6d2@kernel.org> (raw)
In-Reply-To: <20260820211654.8794-1-mcpratt@pm.me>
On 8/20/26 10:17 PM, Michael C. Pratt wrote:
> Although it is not common, some board models from some vendors have
> a MAC address stored in u-boot environment as a quoted form, e.g.
>
> ethaddr="AA:BB:CC:DD:EE:FF"
>
> This is acceptable formatting for a u-boot environment variable, however,
> it makes parsing MACs in post processing more variable and currently fails.
>
> Add a second attempt when initial processing of the MAC address fails,
> by allowing a longer length and try parsing again if it seems to be quoted.
>
> The mac_pton() function has strict behavior on the length and location
> of delimiters for each octet and that each digit is hexadecimal,
> so attempting different offsets of the same string is not problematic.
>
> Signed-off-by: Michael C. Pratt <mcpratt@pm.me>
> ---
> drivers/nvmem/layouts/u-boot-env.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
this patch looks stale as
commit 45cb0223740b863089ce3cc523155cf7a55e1479
Author: Tomasz Maciej Nowak <tmn505@gmail.com>
Date: Sat May 30 21:53:33 2026 +0100
nvmem: layouts: u-boot-env: check earlier for ethaddr length
already has some changes in this area,
--srini
>
> diff --git a/drivers/nvmem/layouts/u-boot-env.c b/drivers/nvmem/layouts/u-boot-env.c
> index f27f387bb52a..ff71c3c25d42 100644
> --- a/drivers/nvmem/layouts/u-boot-env.c
> +++ b/drivers/nvmem/layouts/u-boot-env.c
> @@ -38,11 +38,15 @@ static int u_boot_env_read_post_process_ethaddr(void *context, const char *id, i
> {
> u8 mac[ETH_ALEN];
>
> + /* Handle quotation which increases length by 2 bytes if present. */
> if (bytes != MAC_ADDR_STR_LEN)
> - return -EINVAL;
> + if (bytes != MAC_ADDR_STR_LEN + 2 && !(*(char *)buf == '"' || *(char *)buf == '\''))
> + return -EINVAL;
>
> + /* Handle quotation which offsets data by 1 byte if present. */
> if (!mac_pton(buf, mac))
> - return -EINVAL;
> + if (!mac_pton(buf + 1, mac))
> + return -EINVAL;
>
> if (index)
> eth_addr_add(mac, index);
prev parent reply other threads:[~2026-09-20 16:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-20 21:17 Michael C. Pratt
2026-09-20 16:44 ` Srinivas Kandagatla [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=5a153e76-a149-4084-92cb-785f7b47c6d2@kernel.org \
--to=srini@kernel.org \
--cc=ansuelsmth@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mcpratt@pm.me \
--cc=rafal@milecki.pl \
/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
all inboxes | Powered by JetHome®