From patchwork Mon Apr 8 19:20:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1081423 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="bEhkjuk5"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 44dL405D2gz9sPb for ; Tue, 9 Apr 2019 05:25:36 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 6C4CBC21E08; Mon, 8 Apr 2019 19:23:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 0E87EC21E3B; Mon, 8 Apr 2019 19:22:46 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3D157C21E34; Mon, 8 Apr 2019 19:22:39 +0000 (UTC) Received: from mail-it1-f193.google.com (mail-it1-f193.google.com [209.85.166.193]) by lists.denx.de (Postfix) with ESMTPS id B02F4C21E07 for ; Mon, 8 Apr 2019 19:22:34 +0000 (UTC) Received: by mail-it1-f193.google.com with SMTP id q14so1025194itk.0 for ; Mon, 08 Apr 2019 12:22:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mS54xxfMHSihMBEMy1nXrhPUz1it7VfsUvttZrufBfE=; b=bEhkjuk5XCF2feLxSQgmWcv14Zlcl06O07FEiGI4NxkgcXNLU5DP7XbkqFmIsGwzXJ osxFwgkKha1rFa0cngOXN56gBVy8yBAYorJqxW/8bhw6cwY7rGiPnL2+hoRZJ3bwZR/0 AsdJ2st/up+Ez6uWf67OWICdVK8RygjwhPHKU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mS54xxfMHSihMBEMy1nXrhPUz1it7VfsUvttZrufBfE=; b=iLtE0/xCtEwBU3yOCyFX2Op2OagmADGsFnhPR5b18VA154MATga7PugdoS7Adp8dH5 gMWdZi037TPJW9jF90OdGlvZIwtfFxkgd0oyPw7w/UASYMP/BCumjEWK4yW2bYQu29zS DzhcBm/8BiJsQDfd4kaUq+hO+OErvdTBW1TnZ90A8BT+QIae4uq5+GwLEIfxe6qUb3N2 tQ5dz1SKcFpkWWbFfkqvUsUDJrsjWiED5K5dzLZ3gtkZ4A9qdSBH9MetYri3sWj9CxYV qzKffmhKkvp3ggnCzPFiznuqgByI0WSGmEQUN7q358bXQdKNm0Zz6XoA3YPxDc4JUYil kg8w== X-Gm-Message-State: APjAAAUDV9LfIPJyu6fRFATiVDn7AdNaSjh3NMOm8BoMxQcQRQYo83o/ EaxlI7emwDh9hcvjWs0lGKsGPg15qgU= X-Google-Smtp-Source: APXvYqyQnFHyzGz9MPbjpHzWGggphrSmnKEzreHXQkSV2amCd/uRUgXvP/WosAMhSjSmaZQ9UFewhg== X-Received: by 2002:a02:5143:: with SMTP id s64mr23367421jaa.54.1554751353560; Mon, 08 Apr 2019 12:22:33 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id b17sm12710672ion.0.2019.04.08.12.22.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 12:22:33 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 8 Apr 2019 13:20:45 -0600 Message-Id: <20190408192053.236725-6-sjg@chromium.org> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog In-Reply-To: <20190408192053.236725-1-sjg@chromium.org> References: <20190408192053.236725-1-sjg@chromium.org> MIME-Version: 1.0 Subject: [U-Boot] [PATCH v2 05/13] bootstage: Allow calling bootstage_mark() before bootstage_init() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 Signed-off-by: Simon Glass --- Changes in v2: - Add new patch to allow calling bootstage_mark() before bootstage_init() common/bootstage.c | 7 +++++++ 1 file changed, 7 insertions(+) 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++;