bootstage: Allow calling bootstage_mark() before bootstage_init()
authorSimon Glass <sjg@chromium.org>
Mon, 8 Apr 2019 19:20:45 +0000 (13:20 -0600)
committerSimon Glass <sjg@chromium.org>
Wed, 24 Apr 2019 02:26:43 +0000 (20:26 -0600)
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>
common/bootstage.c

index 9793b85..56ef91a 100644 (file)
@@ -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++;