mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <>
Cc: Ahmad Fatoum <>
Subject: [PATCH master 2/2] common: don't fixup empty serial/machine_compatible strings
Date: Mon, 18 Jul 2022 13:48:24 +0200	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

There is no point in fixing up an empty string into the kernel device
tree, yet this can happen when globalvar_add_simple_string() is called
for the variable at least once as the function replaces NULL with an
allocated empty string. globalvar_add_simple_string() was called
unconditionally for of.kernel.add_machine_compatible, which in turn
led to always fixing up an empty string as the top-most compatible.

Resolve this by having barebox_get_(of_machine_compatible|serial_number)
return NULL for the empty string as well.

Fixes: 81dd24a0946c ("of: add generic of_prepend_machine_compatible()")
Fixes: f6756e9ce6f2 ("common: add $global.serial_number with device tree fixup")
Signed-off-by: Ahmad Fatoum <>
 common/misc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/common/misc.c b/common/misc.c
index 0f6de3e9e5ef..e0e32f47c59d 100644
--- a/common/misc.c
+++ b/common/misc.c
@@ -191,6 +191,8 @@ void barebox_set_serial_number(const char *__serial_number)
 const char *barebox_get_serial_number(void)
+	if (!serial_number || *serial_number == '\0')
+		return NULL;
 	return serial_number;
@@ -204,6 +206,8 @@ void barebox_set_of_machine_compatible(const char *__compatible)
 const char *barebox_get_of_machine_compatible(void)
+	if (!of_machine_compatible || *of_machine_compatible == '\0')
+		return NULL;
 	return of_machine_compatible;

  reply	other threads:[~2022-07-18 11:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-18 11:48 [PATCH master 1/2] regulator: handle regulator_get_voltage(NULL) gracefully Ahmad Fatoum
2022-07-18 11:48 ` Ahmad Fatoum [this message]
2022-08-08 14:21 ` 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:

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

  git send-email \ \ \ \

* 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