From nobody Mon Apr 6 10:45:19 2026 Received: from terefe.re (terefe.re [5.255.96.200]) (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 65AC63EF0CF for ; Thu, 19 Mar 2026 17:20:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=5.255.96.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773940848; cv=none; b=rKQUzlC4+GP3KWDlHNbuH/8/h48mtvOJnioQmgVOwVzfrMnOpjEJbaGSiHRYshgXagBrDDjXmc7Z4/mWAPnIYeFcyYi5JsA3CuCO5PJg3QHJ4ysHIxn+71xSn79rtcfyTQUY8HbPTbkRW3rGJSS7wYCdKcKlZoYip2zMKkVpY38= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773940848; c=relaxed/simple; bh=cbTn/adwIP4O9Z2tFMMaa0BwtpodH9aXdUiusJj2S0c=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=BVZjD4L6MYESMAfZQNhtGrebYsOlQLo2dO4dP9coSWw7jpDTRTl5ScedP4NGTz4v1akndOMww6IB8V1VL+M+85fIRXmxJjVX2bF5EiLQB8eQgXpCvERls/WdYP1l7Cc+Yo1brhBb4gFY+M2VaXGritoysqbu9Jrp2V3dqfawtcs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=terefe.re; spf=pass smtp.mailfrom=terefe.re; dkim=pass (2048-bit key) header.d=terefe.re header.i=@terefe.re header.b=lCfB5bLI; arc=none smtp.client-ip=5.255.96.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=terefe.re Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=terefe.re Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=terefe.re header.i=@terefe.re header.b="lCfB5bLI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=terefe.re; s=default; t=1773940362; bh=cbTn/adwIP4O9Z2tFMMaa0BwtpodH9aXdUiusJj2S0c=; h=From:To:Cc:Subject:Date:From; b=lCfB5bLIimuuvuEIpYMcuXaGSHzJFfVjjpj6UEjr5kKybxh5FTNYAoeOxnmQ7UuFM DON9vI/EsWGHIRMFImMvy9NrPqUFIQf/OTc3H9fS7BDKqDMxFm6uKGUz6BSAdfZynI k8B6R/YbI8Hb8cAxyEBNRqDCdIUsUQhhfbsQwzd8cgTnBjei9AsCL64SwrOOcV/wWg Ns3IEjhHnK0w/soWOwyHC5D4bdL1Ik8gxXb/UvA/O5iBvAx4kV7zUN35kuO3HbKU5m ubPaa3wfwjuNPmmFH9C01tPMMbdykiy4PsSn+BHg9lthRI6JHUEp4M/phg7w5fy2SE pZk4Nf7Vuayig== Received: from terefe.re (unknown [212.106.161.86]) by terefe.re (Postfix) with ESMTPSA id EF927202E0; Thu, 19 Mar 2026 18:12:41 +0100 (CET) From: Tomasz Maciej Nowak To: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= , Srinivas Kandagatla , linux-kernel@vger.kernel.org Cc: Tomasz Maciej Nowak Subject: [PATCH] nvmem: layouts: u-boot-env: check earlier for ethaddr length Date: Thu, 19 Mar 2026 18:12:36 +0100 Message-ID: <20260319171236.48325-1-tmn505@terefe.re> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Tomasz Maciej Nowak Unfortunately the ethaddr value in U-Boot environment might be enclosed in single/double quotes or be something completely different, which can make it longer than ETH_ALEN, then nvmem will return EINVAL. Move the check for length earlier, so even if ethaddr is something different, nvmem could still present it. Signed-off-by: Tomasz Maciej Nowak --- drivers/nvmem/layouts/u-boot-env.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/nvmem/layouts/u-boot-env.c b/drivers/nvmem/layouts/u-b= oot-env.c index f27f387bb52a..dd3f541728bf 100644 --- a/drivers/nvmem/layouts/u-boot-env.c +++ b/drivers/nvmem/layouts/u-boot-env.c @@ -38,9 +38,6 @@ static int u_boot_env_read_post_process_ethaddr(void *con= text, const char *id, i { u8 mac[ETH_ALEN]; =20 - if (bytes !=3D MAC_ADDR_STR_LEN) - return -EINVAL; - if (!mac_pton(buf, mac)) return -EINVAL; =20 @@ -75,7 +72,7 @@ static int u_boot_env_parse_cells(struct device *dev, str= uct nvmem_device *nvmem info.offset =3D data_offset + value - data; info.bytes =3D strlen(value); info.np =3D of_get_child_by_name(dev->of_node, info.name); - if (!strcmp(var, "ethaddr")) { + if ((!strcmp(var, "ethaddr")) && (info.bytes =3D=3D MAC_ADDR_STR_LEN)) { info.raw_len =3D strlen(value); info.bytes =3D ETH_ALEN; info.read_post_process =3D u_boot_env_read_post_process_ethaddr; --=20 2.53.0