diff options
author | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2021-08-17 08:03:20 +0300 |
---|---|---|
committer | Stefan Roese <sr@denx.de> | 2021-09-01 09:09:24 +0300 |
commit | f858bb2e6c191da3981838937950cb3c98e488fe (patch) | |
tree | 5af2b8e0af165d7d13b361d8bb2535b5050915db /tools | |
parent | e23162c805d46e7f6d11ba07f397b5e3e3750fda (diff) | |
download | u-boot-f858bb2e6c191da3981838937950cb3c98e488fe.tar.xz |
kwbimage: check fopen() return value
Always check the return value of fopen().
This resolves Coverity CID 338491:
Null pointer dereferences (NULL_RETURNS)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Pali Rohár <pali@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/kwbimage.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 9fab04ce88..b2694888d9 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -832,6 +832,12 @@ static int kwb_dump_fuse_cmds(struct secure_hdr_v1 *sec_hdr) if (!strcmp(e->name, "a38x")) { FILE *out = fopen("kwb_fuses_a38x.txt", "w+"); + if (!out) { + fprintf(stderr, "Couldn't open eFuse settings: '%s': %s\n", + "kwb_fuses_a38x.txt", strerror(errno)); + return -ENOENT; + } + kwb_dump_fuse_cmds_38x(out, sec_hdr); fclose(out); goto done; @@ -1060,6 +1066,11 @@ int export_pub_kak_hash(RSA *kak, struct secure_hdr_v1 *secure_hdr) int res; hashf = fopen("pub_kak_hash.txt", "w"); + if (!hashf) { + fprintf(stderr, "Couldn't open hash file: '%s': %s\n", + "pub_kak_hash.txt", strerror(errno)); + return 1; + } res = kwb_export_pubkey(kak, &secure_hdr->kak, hashf, "KAK"); |