For double buffering to work, the target buffer must always be big
enough to hold all data. This can only be ensured if buffers are of
equal size, otherwise one must be smaller and we risk data loss
when copying from the bigger to the smaller.

Signed-off-by: Andreas Fenkart <andreas.fenk...@digitalstrom.com>
---
 tools/env/fw_env.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index 06cf63d..60a7394 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -1373,12 +1373,21 @@ static int parse_config ()
                return -1;
        }
 
-       if (HaveRedundEnv && stat (DEVNAME (1), &st)) {
-               fprintf (stderr,
-                       "Cannot access MTD device %s: %s\n",
-                       DEVNAME (1), strerror (errno));
-               return -1;
+       if (HaveRedundEnv) {
+               if (stat(DEVNAME(1), &st)) {
+                       fprintf(stderr,
+                               "Cannot access MTD device %s: %s\n",
+                               DEVNAME(1), strerror(errno));
+                       return -1;
+               }
+
+               if (ENVSIZE(0) != ENVSIZE(1)) {
+                       fprintf(stderr,
+                               "Redundant environments are not of equal size");
+                       return -1;
+               }
        }
+
        return 0;
 }
 
-- 
2.8.1

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to