diff mbox series

[U-Boot,v2,05/13] bootstage: Allow calling bootstage_mark() before bootstage_init()

Message ID 20190408192053.236725-6-sjg@chromium.org
State Accepted
Commit 173577252f2bebaf17851ce8128ba522f27fb6dd
Delegated to: Simon Glass
Headers show
Series sandbox: Tidy up initcall and tracing | expand

Commit Message

Simon Glass April 8, 2019, 7:20 p.m. UTC
It is possible for this to happen if something goes wrong very early in
the init sequence. Add a check for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2:
- Add new patch to allow calling bootstage_mark() before bootstage_init()

 common/bootstage.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Simon Glass April 22, 2019, 2:38 a.m. UTC | #1
It is possible for this to happen if something goes wrong very early in
the init sequence. Add a check for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2:
- Add new patch to allow calling bootstage_mark() before bootstage_init()

 common/bootstage.c | 7 +++++++
 1 file changed, 7 insertions(+)

Applied to u-boot-dm, thanks!
diff mbox series

Patch

diff --git a/common/bootstage.c b/common/bootstage.c
index 9793b85d4e4..56ef91ad859 100644
--- a/common/bootstage.c
+++ b/common/bootstage.c
@@ -99,6 +99,13 @@  ulong bootstage_add_record(enum bootstage_id id, const char *name,
 	struct bootstage_data *data = gd->bootstage;
 	struct bootstage_record *rec;
 
+	/*
+	 * initf_bootstage() is called very early during boot but since hang()
+	 * calls bootstage_error() we can be called before bootstage is set up.
+	 * Add a check to avoid this.
+	 */
+	if (!data)
+		return mark;
 	if (flags & BOOTSTAGEF_ALLOC)
 		id = data->next_id++;