'close()' clobbers the 'errno' value from the erase command. So it must be done *after* the check for ENOSYS to ingnore it correctly. Signed-off by: Juergen Beisert <j.beisert@xxxxxxxxxxxxxx> --- commands/saveenv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) Index: u-boot-v2/commands/saveenv.c =================================================================== --- u-boot-v2.orig/commands/saveenv.c +++ u-boot-v2/commands/saveenv.c @@ -62,14 +62,15 @@ static int do_saveenv(cmd_tbl_t *cmdtp, ret = erase(fd, ~0, 0); - close(fd); - /* ENOSYS is no error here, many devices do not need it */ if (ret && errno != -ENOSYS) { printf("could not erase %s: %s\n", filename, errno_str()); + close(fd); return 1; } + close(fd); + ret = envfs_save(filename, dirname); if (ret) { printf("saveenv failed\n"); -- Pengutronix e.K. | Juergen Beisert | Linux Solutions for Science and Industry | Phone: +49-8766-939 228 | Vertretung Sued/Muenchen, Germany | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de/ | _______________________________________________ u-boot-v2 mailing list u-boot-v2@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/u-boot-v2