From patchwork Wed May 12 14:09:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kunihiko Hayashi X-Patchwork-Id: 435535 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp4862421jao; Wed, 12 May 2021 07:09:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywB379Acru92NHvHAu/D5p4oSbO3JExS3/I51xis/pG7mxmz7hWjSLdBcBYYwh8e4ArT10 X-Received: by 2002:a17:906:9246:: with SMTP id c6mr38571031ejx.10.1620828576553; Wed, 12 May 2021 07:09:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620828576; cv=none; d=google.com; s=arc-20160816; b=zpDoe2Rzcw802EPe3rjf9+dia/k8q/8ccF3spY+6FGrA3tKZzX9DfH90ZqgSJe4/Kk bKOJuYNIH7/DrShMmderBGjiuXQG5XXXinkLQIRNjrE3hqPvw2m6sFCjIM5K0uisErIY EvSVCUwnEwNCbG6pTf+HyNATbyKupYJs9FT4LX6szISiCZqsBxeFeb80BJ/C4l2Ztwe7 3ZKgjN8OU/yvdr8GxQWBdEg0KcS2hb5c7w47RlGFI2gFozvkxbj0KC9hHYfnld3DigLo tnU5tpTo3dtVV+Yaurv8S/1Gq486XlsWWiQa5CkQUP2tjMR0uJjVCW6lJen5QH8ezjMD i/ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=nNpcRSTD0tCGX085M4MSujeQNw5JrKCKVrnFTZ3+T4U=; b=tFCl4RsRlw85glWBaWe9tBD5Yc8vEGKmRQbQee07C3+I2+54jwfiDwizG4yvUY+XRq 1i4TJO0cXI/uvYLh3Xg0NFdm6q17Z7RjZJ/faGaIag4QmADYTRjxNi+7ysvoPYdPsTtQ PDPixCYl1F9WfBik/Glu6MoAhod1QlC2EfwDE3qbEU9GC20w4QIOVlQ1B2DQeRZeysgp d9yH/0Ce9wEIyTMbOEBEQhfLpNdh4ggjwskjWBacAUuiv24IYEfSq5132NTAbNUo+ZL4 6LZPuGAwPRdalC1iRaVLIfQVEBOT/IFUSxoKOCVvfIjOM2pYa72K8m6cLRf82RIfKweR RQ1g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id f7si5678154edx.339.2021.05.12.07.09.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 May 2021 07:09:36 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4AA5282D50; Wed, 12 May 2021 16:09:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=socionext.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 3609082D51; Wed, 12 May 2021 16:09:32 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mx.socionext.com (mx.socionext.com [202.248.49.38]) by phobos.denx.de (Postfix) with ESMTP id 7F87482CF1 for ; Wed, 12 May 2021 16:09:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=socionext.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=hayashi.kunihiko@socionext.com Received: from unknown (HELO iyokan2-ex.css.socionext.com) ([172.31.9.54]) by mx.socionext.com with ESMTP; 12 May 2021 23:09:25 +0900 Received: from mail.mfilter.local (m-filter-2 [10.213.24.62]) by iyokan2-ex.css.socionext.com (Postfix) with ESMTP id 4E0972059035; Wed, 12 May 2021 23:09:25 +0900 (JST) Received: from 172.31.9.51 (172.31.9.51) by m-FILTER with ESMTP; Wed, 12 May 2021 23:09:25 +0900 Received: from plum.e01.socionext.com (unknown [10.212.243.119]) by kinkan2.css.socionext.com (Postfix) with ESMTP id B91E5B1D40; Wed, 12 May 2021 23:09:24 +0900 (JST) From: Kunihiko Hayashi To: Joe Hershberger , Wolfgang Denk , Marek Vasut Cc: u-boot@lists.denx.de, Kunihiko Hayashi Subject: [PATCH] env: Leave invalid env for nowhere location Date: Wed, 12 May 2021 23:09:14 +0900 Message-Id: <1620828554-24013-1-git-send-email-hayashi.kunihiko@socionext.com> X-Mailer: git-send-email 2.7.4 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean When CONFIG_ENV_IS_NOWHERE is enabled, env_nowhere_init() sets ENV_INVALID to gd->env_valid, and sets default_environment before relocation to gd->env_addr. After that, env_init() switches gd->env_valid to ENV_VALID by the previous fix. If gd->env_valid is ENV_INVALID, env_get_char() returns relocated default_environment, however, env_get_char() returns gd->env_addr before relocation since gd->env_valid is ENV_VALID, and access to gd->env_addr will cause a fault. This leaves gd->env_valid as ENV_INVALID for "nowhere" location. Cc: Marek Vasut Fixes: 5557eec01cbf ("env: Fix invalid env handling in env_init()") Signed-off-by: Kunihiko Hayashi --- env/env.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/env/env.c b/env/env.c index e534008..3233172 100644 --- a/env/env.c +++ b/env/env.c @@ -336,7 +336,8 @@ int env_init(void) debug("%s: Environment %s init done (ret=%d)\n", __func__, drv->name, ret); - if (gd->env_valid == ENV_INVALID) + if (gd->env_valid == ENV_INVALID + && drv->location != ENVL_NOWHERE) ret = -ENOENT; }