From nobody Sun Jun 14 01:37:58 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 E6818282F10 for ; Mon, 4 May 2026 17:28:53 +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=1777915736; cv=none; b=i33hJj993IFUSVi1Gp7z3u1ifF08t+gOrARSGqpwW/gk/EKkNKD4mV+KVwMbkm2HlRuXh79ak5hYokIKm2ubob+dsloRsWsTDf90X7hjttB1imVBRODb6HACUbMZgEL1eDFaCbpHRoRetc1GZszgedmA5rEHaQmJ78oVfq4lsqk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777915736; c=relaxed/simple; bh=7+YevnzhOXjhCfz6k8U0eFVJocKbqR76N/EWTPbP9jA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=S6Wa0BQ5lfkZbJaWouuqupAUlWkvalO7TyXjhXg35fYRmVVYabyVNDzzZk9dqBmJiQha5S2aI0CaGliRUhGqWEMBf+sQQOdWf2KAbb/JaCI4nxsfRcPPzOmkvzmRuQ5El2LBR+ET1Cvgd4ijVF+BlkfFYJ0wZrWbnOCLFmFyTN4= 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=BH4AQjYG; 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="BH4AQjYG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=terefe.re; s=default; t=1777915272; bh=7+YevnzhOXjhCfz6k8U0eFVJocKbqR76N/EWTPbP9jA=; h=From:To:Cc:Subject:Date:From; b=BH4AQjYG4vS/Gb4xyF5AQdhGah+jOhdZZH6YNQFL+VtdJXbkEI0j/dU5Wsljwz2k+ dhb+HwnigOgAGiTHvkqSPNbEhX3rXADt634xo1zpH5Y4yny9ZF1bQdij41h+OgVP+w 7KDUJTkRpdzphSa+Oo5uS0lYlzNn2jYKv2toD0p0y7pW30JeZNNYeaVNNS+2NiuRD/ yQmrMPtrqI19a+WNpGGNMcvJe21pRImEOAqFGQNKvoyXvOiRJfN9kWR3ACpiM88y0A ardqOBLNwkOcFtqSQ4QTTGIX27lbyR5G/hC7EMxPQt8u4kg+nppM1W7YPGEvdZXNrw BHwkkZFhIOs/g== Received: from terefe.re (unknown [212.106.161.84]) by terefe.re (Postfix) with ESMTPSA id 7F167202C4; Mon, 04 May 2026 19:21:12 +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 v2] nvmem: layouts: u-boot-env: check earlier for ethaddr length Date: Mon, 4 May 2026 19:19:03 +0200 Message-ID: <20260504172103.18061-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 --- v2 Better clarification in commit message 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..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.54.0