From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96AEE48665F for ; Thu, 20 Aug 2026 21:18:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.43.22 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787260698; cv=none; b=I/GSeZZPj1t98V8e6wjF7zkYdTbj1/l4rfqKZioSg59tgj/ZFiY5/qCmfKUxHmYGAFIxMFzmLbh3L+GxXbWWsRBZaO1gpHlt2U8IQ2Y7Jg7vlGB6EaUOSYfz99hi53/nJrI3X9+dWfh1DCR/4yTpGIJXxNVc6BnWjVIcBzVDAm4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787260698; c=relaxed/simple; bh=+DZEKOcH1sS5JpY/3vKDqV4Dsoil18/iDBSiPvoGx+o=; h=Date:To:From:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=eCuw3MpYYA7fdUPwf4R5eQhceM8C61XdJ23jAAGoEiost0hdPA4R0u1d9y2koMW54C+1imYd4y9c8JsvKnRut1xazofhsSW7mvjfIVmM2s9BlOEUaP4szhs8MnOL3YLkPumfV7goSBzl7WwK9lUrvjZI8Xg0GLuydo2nI5JZa0I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me; spf=pass smtp.mailfrom=pm.me; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b=PGM/Dzxe; arc=none smtp.client-ip=185.70.43.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pm.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b="PGM/Dzxe" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1787260680; x=1787519880; bh=BgeKqnrL5wWMYdP2lGeGaPN7GvhGJaLCVSoRe6njqFo=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=PGM/Dzxe2RvkZsTf8IVWbupEbw3ycN3CgeKY9WimArhdBuYpPsoovWzFNkQ3VgcgX 0PgbY2h8hoacqWHnfmtUF8Bu0GIE619cwDqXJ/jbBBAa+6zwIzUb1BXVcATkNzRmuW PXpkhaG3QSHG01QutSMxazFF32HKyPonvkFZDzGCdqqglK8tfc34W4qCLT+x5jUzJF UOkP/hn/j/AMqOblSZ7e4SFHJ2NjIyKv2JChcOfyMg/RK4UtmXO2woRKNlt81gXIsl 0cBh8tYLGmdl2fTCinBiV4CBp0cpyp3JZk9yAHcGJL0Fyu6CoDSB7XoCso3QYOjdLz rBnYlYFWCMtCg== Date: Thu, 20 Aug 2026 21:17:50 +0000 To: linux-kernel@vger.kernel.org From: "Michael C. Pratt" Cc: "Michael C. Pratt" , =?utf-8?Q?Rafa=C5=82_Mi=C5=82ecki?= , Christian Marangi , Srinivas Kandagatla Subject: [PATCH] nvmem: layouts: u-boot-env: handle quotes in MAC post process Message-ID: <20260820211654.8794-1-mcpratt@pm.me> Feedback-ID: 27397442:user:proton X-Pm-Message-ID: d699ea665b45e69a0c54366e7c7cf9164194d582 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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=3D"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 --- drivers/nvmem/layouts/u-boot-env.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/nvmem/layouts/u-boot-env.c b/drivers/nvmem/layouts/u-b= oot-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 *c= ontext, const char *id, i { =09u8 mac[ETH_ALEN]; =20 +=09/* Handle quotation which increases length by 2 bytes if present. */ =09if (bytes !=3D MAC_ADDR_STR_LEN) -=09=09return -EINVAL; +=09=09if (bytes !=3D MAC_ADDR_STR_LEN + 2 && !(*(char *)buf =3D=3D '"' || = *(char *)buf =3D=3D '\'')) +=09=09=09return -EINVAL; =20 +=09/* Handle quotation which offsets data by 1 byte if present. */ =09if (!mac_pton(buf, mac)) -=09=09return -EINVAL; +=09=09if (!mac_pton(buf + 1, mac)) +=09=09=09return -EINVAL; =20 =09if (index) =09=09eth_addr_add(mac, index); --=20 2.30.2