From patchwork Fri May 29 17:51:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 246833 List-Id: U-Boot discussion From: marex at denx.de (Marek Vasut) Date: Fri, 29 May 2020 19:51:15 +0200 Subject: [PATCH] env: Fix invalid env handling in env_init() Message-ID: <20200529175115.627228-1-marex@denx.de> In case the env storage driver marks environment as ENV_INVALID, we must reset the $ret return value to -ENOENT to let the env init code reset the environment to the default one a bit further down. Signed-off-by: Marek Vasut --- env/env.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/env/env.c b/env/env.c index dcc25c030b..024d36fdbe 100644 --- a/env/env.c +++ b/env/env.c @@ -300,6 +300,9 @@ int env_init(void) debug("%s: Environment %s init done (ret=%d)\n", __func__, drv->name, ret); + + if (gd->env_valid == ENV_INVALID) + ret = -ENOENT; } if (!prio)