From nobody Mon May 25 01:17:35 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 CA46D2E7F2C for ; Tue, 19 May 2026 20:22:45 +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=1779222167; cv=none; b=a53GZg3c01Tqc5abr2C+nvdGHZLhg+Do/ylMDeTIiBv366YlWHmNMHOtR2l7pYXZe8z+VFf32/GCgzTrszMfRAtAbeo3UHAcJZX82ltmukycAX9WiGLWk3abEGI0/l2ltwQYuWokrg3T9wvsxhjGEL3nw0Az/o+1PVXzkCEaeiU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779222167; c=relaxed/simple; bh=OP33vvZS1/ovqh61go82eS8CFrBAQgx4ZWFOPkL3tBQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=o68HRwlmNBI2K729Utjt/CGqnkx32X014KyqsXxeHlVgtVeSr2Yyff6FHtAfO7vc5vqVC3k4wKkFLyjvdx1iupDlwVUwIsajL+pvvm1CcEs3O/RkhhZXLSa17SouYopiZ7dUnIeO4941OURARvag9zB5z02aqJIpzQ+rN217VZc= 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=Hk/3cXqT; 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="Hk/3cXqT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=terefe.re; s=default; t=1779222164; bh=OP33vvZS1/ovqh61go82eS8CFrBAQgx4ZWFOPkL3tBQ=; h=From:To:Cc:Subject:Date:From; b=Hk/3cXqTl0mrLahfdLk8PqXclcynjluZzXkQ3LNs87RtIS52NXa6+BZTLkqWkrA2k 8lN3mVUXQL2kmiUtgy2ifqNVWxCsknCottY99Md4r2mLoC+MvEuAQH7QGSwxyZQ5+g mlZCmLcv4h5L53GXZjbxejA4UKU944VugNGTgiFonpu4SYxxdLUGpTsNUkNd/S8CR0 qoHi9tJmHW9jehe+O+vNlxpgJVgFBJ1cE6CvazrSO7sxwTZgKNRPeb1ZSASNxEkoFw Sjp5bb6IS0oXcLT4+22AjMnCnCnqARYAUkL97/zpbabJAP2jzi/9AeXXqqNPiJzIL6 5zPIU142OMzNA== Received: from terefe.re (unknown [212.106.161.84]) by terefe.re (Postfix) with ESMTPSA id ECC832016C; Tue, 19 May 2026 22:22:43 +0200 (CEST) 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 v3] nvmem: layouts: u-boot-env: check earlier for ethaddr length Date: Tue, 19 May 2026 22:19:25 +0200 Message-ID: <20260519202236.551548-1-tmn505@terefe.re> X-Mailer: git-send-email 2.54.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. This can make it different than MAC_ADDR_STR_LEN, which results in EINVAL returned by ethaddr post process. Move the check for length earlier, to skip post processing, so nvmem could still present ethaddr value as a string if the value doesn't match MAC_ADDR_STR_LEN. Signed-off-by: Tomasz Maciej Nowak --- v3 Drop redundant parenthesis v2 Better clarification in commit message Link: https://lore.kernel.org/all/20260504172103.18061-1-tmn505@terefe.re/ v1 Link: https://lore.kernel.org/all/20260319171236.48325-1-tmn505@terefe.re/ 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..33ec2350386f 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.54.0