From patchwork Mon Oct 21 23:26:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1180931 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 (no SPF record) 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="SXwibjrC"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46xtFP0nG0z9sCJ for ; Tue, 22 Oct 2019 10:31:37 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id C2928C21E47; Mon, 21 Oct 2019 23:28:57 +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 0624EC21E07; Mon, 21 Oct 2019 23:28:56 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6445EC21DAF; Mon, 21 Oct 2019 23:27:15 +0000 (UTC) Received: from mail-io1-f65.google.com (mail-io1-f65.google.com [209.85.166.65]) by lists.denx.de (Postfix) with ESMTPS id C84ECC21E0B for ; Mon, 21 Oct 2019 23:27:12 +0000 (UTC) Received: by mail-io1-f65.google.com with SMTP id 1so6765454iou.4 for ; Mon, 21 Oct 2019 16:27:12 -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=zTp7symrQzoQTUal0cAV3Z5AXhFCKEpgzqIrjBP6NLQ=; b=SXwibjrCwzUEAG+qljPvLq/vO5pCJVJ/Rer9RD7dKJnfkLEDF05pkTtaVBO6wey4TJ ZMpao/tVO+a16BAgFBGHyaUZ7FEIMCgbZ4iefF8xoatgoOiCSvbKtFvDdG7SkPOcJtlP ImG2WwjH9ldPhonpdCZWA0mh+e8SHWEKgQT+M= 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=zTp7symrQzoQTUal0cAV3Z5AXhFCKEpgzqIrjBP6NLQ=; b=Iq0deQebM3M7Wmsme/80zu9nSCizkT4sDx7hvX4BgwJ/dHzRZ9wIE8XpeptthN92MS zyewjjsa7YJpwyb5W0YimRNV5tqXWQhiAuss6ZtuiOXoI+Qp5b8J5O3d/eZIhwqf1JP/ 0xcwVIz2O78NEIBxeLFIcQah08zqo9+5nuG6ei5ACv6+WysYTiLR09Oa7zuOkL36YlCV WUA+ZYxu6xhkxfHR09hDnjnZOre19cNBNcctSJuGkla2CXb4EAAN4eyXALm8jg6xRedB F44NG2bx7U1qPEAXZZ09hG8amuqqVhRfI74kPcnacsswBdm7x+x0KgQ4QsvrnwTgyEk2 P5yA== X-Gm-Message-State: APjAAAWl5sL2vAmne0idHC+XWtQH+D5dbI6TBd2Yd0rqiQ5Yu1o45oiR 5a5BqrBgMSQrVJ5IsbFjDvqDFwVzky4mlg== X-Google-Smtp-Source: APXvYqxK+KXemkpmamKe28Ul5aBWFN6mrcTU2GDw5AxDd+QanCw3kOQtsB0w2wEEobAM7NNsl+CASg== X-Received: by 2002:a6b:ed1a:: with SMTP id n26mr897928iog.112.1571700431226; Mon, 21 Oct 2019 16:27:11 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id u190sm6879206ilc.36.2019.10.21.16.27.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 16:27:10 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 21 Oct 2019 17:26:49 -0600 Message-Id: <20191021232652.132164-8-sjg@chromium.org> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191021232652.132164-1-sjg@chromium.org> References: <20191021232652.132164-1-sjg@chromium.org> MIME-Version: 1.0 Subject: [U-Boot] [PATCH v2 07/10] bootstage: Avoid conflicts between stash/unstash 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" At present there is a single shared address for bootstage data in both TPL and SPL. If SPL unstashs TPL bootstage info and then stashes it again to pass it to U-Boot, the new stash overwrites the strings of the old stash. Fix this by duplicating the strings into the malloc() region. This should be a small code. Fix the header-file order at the same time. This problem doesn't happen at the next stage (SPL->U-Boot) since U-Boot relocates the boostage data. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- Changes in v2: None common/bootstage.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/bootstage.c b/common/bootstage.c index fe36bac0474..4557ed4508c 100644 --- a/common/bootstage.c +++ b/common/bootstage.c @@ -10,9 +10,10 @@ */ #include -#include #include +#include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -472,6 +473,8 @@ int bootstage_unstash(const void *base, int size) for (rec = data->record + data->next_id, i = 0; i < hdr->count; i++, rec++) { rec->name = ptr; + if (spl_phase() == PHASE_SPL) + rec->name = strdup(ptr); /* Assume no data corruption here */ ptr += strlen(ptr) + 1;