From patchwork Sat Jun 27 08:19:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 243021 List-Id: U-Boot discussion From: xypron.glpk at gmx.de (Heinrich Schuchardt) Date: Sat, 27 Jun 2020 10:19:30 +0200 Subject: [PATCH 1/1] fs: error handling in do_load() Message-ID: <20200627081930.18795-1-xypron.glpk@gmx.de> If a file cannot be loaded, show an error message. Set the EFI boot device only after successfully loading a file. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- fs/fs.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) -- 2.27.0 diff --git a/fs/fs.c b/fs/fs.c index ad4caaeb1e..12fa5a6489 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -715,15 +715,18 @@ int do_load(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], else pos = 0; -#ifdef CONFIG_CMD_BOOTEFI - efi_set_bootdev(argv[1], (argc > 2) ? argv[2] : "", - (argc > 4) ? argv[4] : ""); -#endif time = get_timer(0); ret = _fs_read(filename, addr, pos, bytes, 1, &len_read); time = get_timer(time); - if (ret < 0) + if (ret < 0) { + printf("Failed to load '%s'\n", filename); return 1; + } + +#ifdef CONFIG_CMD_BOOTEFI + efi_set_bootdev(argv[1], (argc > 2) ? argv[2] : "", + (argc > 4) ? argv[4] : ""); +#endif printf("%llu bytes read in %lu ms", len_read, time); if (time > 0) {