[PATCH master 2/2] common: don't fixup empty serial/machine_compatible strings
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Jul 18 04:48:24 PDT 2022
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 <a.fatoum at pengutronix.de>
---
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;
}
--
2.30.2
More information about the barebox
mailing list