summaryrefslogtreecommitdiff
path: root/tools/env/fw_env.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/env/fw_env.c')
-rw-r--r--tools/env/fw_env.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index c251e2e6ba..c9a8774ace 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -1733,6 +1733,7 @@ static int find_nvmem_device(void)
while (!nvmem && (dent = readdir(dir))) {
FILE *fp;
+ size_t size;
if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, "..")) {
continue;
@@ -1748,7 +1749,14 @@ static int find_nvmem_device(void)
continue;
}
- fread(buf, sizeof(buf), 1, fp);
+ size = fread(buf, sizeof(buf), 1, fp);
+ if (size != 1) {
+ fprintf(stderr,
+ "read failed about %s\n", comp);
+ fclose(fp);
+ return -EIO;
+ }
+
if (!strcmp(buf, "u-boot,env")) {
bytes = asprintf(&nvmem, "%s/%s/nvmem", path, dent->d_name);