mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] common: oftree: trim leading spaces from bootargs
@ 2020-03-20 16:07 Clement Leger
  2020-03-23  7:19 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Clement Leger @ 2020-03-20 16:07 UTC (permalink / raw)
  To: Sascha Hauer, barebox; +Cc: Clement Leger

When barebox concatenates all dynamic bootargs string for linux, if they
are empty, the resulting string might be composed of only spaces.
Currently, there is no check for such string and it leads to
overwriting bootargs in the device tree by an empty string. To avoid
this behavior, use skip_spaces to trim leading spaces and then check if
the string is empty. If so, simply returns and don't patch device tree
bootargs.

Signed-off-by: Clement Leger <cleger@kalray.eu>
---
 common/oftree.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/common/oftree.c b/common/oftree.c
index 09cb66021..36906e86f 100644
--- a/common/oftree.c
+++ b/common/oftree.c
@@ -151,6 +151,10 @@ static int of_fixup_bootargs(struct device_node *root, void *unused)
 	if (!str)
 		return 0;
 
+	str = skip_spaces(str);
+	if (strlen(str) == 0)
+		return 0;
+
 	node = of_create_node(root, "/chosen");
 	if (!node)
 		return -ENOMEM;
-- 
2.15.0.276.g89ea799


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] common: oftree: trim leading spaces from bootargs
  2020-03-20 16:07 [PATCH] common: oftree: trim leading spaces from bootargs Clement Leger
@ 2020-03-23  7:19 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2020-03-23  7:19 UTC (permalink / raw)
  To: Clement Leger; +Cc: barebox

On Fri, Mar 20, 2020 at 05:07:20PM +0100, Clement Leger wrote:
> When barebox concatenates all dynamic bootargs string for linux, if they
> are empty, the resulting string might be composed of only spaces.
> Currently, there is no check for such string and it leads to
> overwriting bootargs in the device tree by an empty string. To avoid
> this behavior, use skip_spaces to trim leading spaces and then check if
> the string is empty. If so, simply returns and don't patch device tree
> bootargs.
> 
> Signed-off-by: Clement Leger <cleger@kalray.eu>
> ---
>  common/oftree.c | 4 ++++
>  1 file changed, 4 insertions(+)

Applied, thanks

Sascha


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-23  7:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-20 16:07 [PATCH] common: oftree: trim leading spaces from bootargs Clement Leger
2020-03-23  7:19 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox