All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [PATCH] env: Leave invalid env for nowhere location
Date: Sun, 16 May 2021 19:19:01 +0200	[thread overview]
Message-ID: <29950f49-c47a-3d13-7113-402235de6d76@denx.de> (raw)
In-Reply-To: <1620828554-24013-1-git-send-email-hayashi.kunihiko@socionext.com>

On 5/12/21 4:09 PM, Kunihiko Hayashi wrote:
> 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 <marex@denx.de>
> Fixes: 5557eec01cbf ("env: Fix invalid env handling in env_init()")
> Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
> ---
>   env/env.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> 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;
>   	}

I'm CCing Tim, it would be good to get a TB from him.

  reply	other threads:[~2021-05-16 17:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-12 14:09 [PATCH] env: Leave invalid env for nowhere location Kunihiko Hayashi
2021-05-16 17:19 ` Marek Vasut [this message]
2021-05-25  6:30   ` Kunihiko Hayashi
2021-05-25  7:35 ` Marek Vasut
2021-06-03 16:15   ` Kunihiko Hayashi
2021-06-06 18:08     ` Marek Vasut
2021-06-07  7:54       ` Kunihiko Hayashi
2021-06-07 17:33         ` Marek Vasut
2021-06-08  7:54           ` Kunihiko Hayashi
2021-06-10  1:07             ` Marek Vasut
2021-06-10  8:25               ` Kunihiko Hayashi
2021-06-10 13:28                 ` Marek Vasut

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=29950f49-c47a-3d13-7113-402235de6d76@denx.de \
    --to=marex@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.