mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 07:03:28 -04:00
nvmem: layouts: u-boot-env: check earlier for ethaddr length
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 <tmn505@gmail.com> Signed-off-by: Srinivas Kandagatla <srini@kernel.org> Link: https://patch.msgid.link/20260530205333.117458-15-srini@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
804a588eb5
commit
45cb022374
@@ -38,9 +38,6 @@ static int u_boot_env_read_post_process_ethaddr(void *context, const char *id, i
|
||||
{
|
||||
u8 mac[ETH_ALEN];
|
||||
|
||||
if (bytes != MAC_ADDR_STR_LEN)
|
||||
return -EINVAL;
|
||||
|
||||
if (!mac_pton(buf, mac))
|
||||
return -EINVAL;
|
||||
|
||||
@@ -75,7 +72,7 @@ static int u_boot_env_parse_cells(struct device *dev, struct nvmem_device *nvmem
|
||||
info.offset = data_offset + value - data;
|
||||
info.bytes = strlen(value);
|
||||
info.np = of_get_child_by_name(dev->of_node, info.name);
|
||||
if (!strcmp(var, "ethaddr")) {
|
||||
if (!strcmp(var, "ethaddr") && info.bytes == MAC_ADDR_STR_LEN) {
|
||||
info.raw_len = strlen(value);
|
||||
info.bytes = ETH_ALEN;
|
||||
info.read_post_process = u_boot_env_read_post_process_ethaddr;
|
||||
|
||||
Reference in New Issue
Block a user