env: fat, ubi: Fix gd->env_valid for the first write
authorTom Rini <trini@konsulko.com>
Tue, 21 Oct 2025 20:37:01 +0000 (14:37 -0600)
committerTom Rini <trini@konsulko.com>
Fri, 24 Oct 2025 19:47:50 +0000 (13:47 -0600)
commitcf262e16080abcd587f47d0bbc8fa84558abcf89
treec43f37eb8778d5d37a61190a04a6d04a8870cdb7
parent38f40e6de6029686356a1b786087385ae974d354
env: fat, ubi: Fix gd->env_valid for the first write

As resolved and explained in detail in commit e589d5822cac ("env: spi:
Fix gd->env_valid for the first write") and archived discussion there is
a corner case where we don't do the right thing with redundant
environments. This same exact check was present in the mmc code and
resolved with commit 813a0df27a8a ("env: Invert gd->env_valid for
env_mmc_save") and in the discussion of that patch, I noted that both
fat and ubi (and at the time, sf) were doing the same thing. Take the
time now to correct fat and ubi environment.

Signed-off-by: Tom Rini <trini@konsulko.com>
env/fat.c
env/ubi.c