mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: "Leonard Göhrs" <l.goehrs@pengutronix.de>,
	"Ahmad Fatoum" <a.fatoum@barebox.org>
Subject: [PATCH master] tlv: drop assigned MAC addresses from fixup
Date: Tue,  5 Aug 2025 20:53:44 +0200	[thread overview]
Message-ID: <20250805185344.2691524-1-a.fatoum@barebox.org> (raw)

A TLV blob may contain more MAC addresses than barebox can assign for
the network devices it knows about. In that case, barebox should assign
as many MAC addresses as it can and fix up the remainder, so the OS can
deal with it.

This got broken during refactoring in reply to upstreaming feedback:
instead of calling string_to_ethaddr on a string, it was called on a
6-byte MAC address.

Swap this to get back the intended behavior.

Fixes: 0b444f05f713 ("common: add barebox TLV support")
Link: https://github.com/linux-automation/meta-lxatac/issues/275
Reported-by: Leonard Göhrs <l.goehrs@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 common/tlv/parser.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/common/tlv/parser.c b/common/tlv/parser.c
index 468eeafceda1..fc46092650b1 100644
--- a/common/tlv/parser.c
+++ b/common/tlv/parser.c
@@ -95,8 +95,8 @@ int of_tlv_fixup(struct device_node *root, void *ctx)
 
 	list_for_each_entry(addr, &ethaddr_list, list) {
 		char propname[sizeof("address-4294967295")];
-		const u8 *enetaddr_a;
-		u8 enetaddr_b[ETH_ALEN];
+		const char *enetaddr_tlv_str;
+		u8 enetaddr_tlv[ETH_ALEN];
 		struct property *pp;
 
 		if (!eth_of_get_fixup_node(root, NULL, addr->ethid))
@@ -107,11 +107,11 @@ int of_tlv_fixup(struct device_node *root, void *ctx)
 		if (!pp)
 			continue;
 
-		enetaddr_a = of_property_get_value(pp);
-		if (string_to_ethaddr(addr->ethaddr, enetaddr_b))
+		enetaddr_tlv_str = of_property_get_value(pp);
+		if (string_to_ethaddr(enetaddr_tlv_str, enetaddr_tlv))
 			continue;
 
-		if (memcmp(enetaddr_a, enetaddr_b, ETH_ALEN))
+		if (memcmp(enetaddr_tlv, addr->ethaddr, ETH_ALEN))
 			continue;
 
 		of_delete_property(pp);
-- 
2.39.5




             reply	other threads:[~2025-08-05 18:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-05 18:53 Ahmad Fatoum [this message]
2025-08-06  6:32 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250805185344.2691524-1-a.fatoum@barebox.org \
    --to=a.fatoum@barebox.org \
    --cc=barebox@lists.infradead.org \
    --cc=l.goehrs@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox