diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2022-07-18 13:48:24 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-08-08 16:21:27 +0200 |
commit | 1da26bfb9da2d0d0054169b15d90e9a2c85ae902 (patch) | |
tree | 876e3428e6433f85df27feeec3d38d68f5ac98e2 | |
parent | 2fdb13043f0f75075332a0bb5083dd278430c064 (diff) | |
download | barebox-1da26bfb9da2d0d0054169b15d90e9a2c85ae902.tar.gz barebox-1da26bfb9da2d0d0054169b15d90e9a2c85ae902.tar.xz |
common: don't fixup empty serial/machine_compatible strings
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@pengutronix.de>
Link: https://lore.barebox.org/20220718114824.2632364-2-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | common/misc.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/common/misc.c b/common/misc.c index 0f6de3e9e5..e0e32f47c5 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; } |