aboutsummaryrefslogtreecommitdiff
path: root/util/cbfstool/common.c
diff options
context:
space:
mode:
authorPatrick Georgi <patrick.georgi@coresystems.de>2009-09-15 08:21:46 +0000
committerPatrick Georgi <patrick.georgi@coresystems.de>2009-09-15 08:21:46 +0000
commit45d8a83b29e9eb2e20f4ca39914a42561a2c1f79 (patch)
treee4060262f2811d96ab9b11b69ddb2c062e565062 /util/cbfstool/common.c
parentfd9c9b8ff8326c07bd63b39ab85bd68f6fb6a011 (diff)
More error checking when trying to open files in
cbfstool. (trivial) Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de> Acked-by: Patrick Georgi <patrick.georgi@coresystems.de> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@4634 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util/cbfstool/common.c')
-rw-r--r--util/cbfstool/common.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/util/cbfstool/common.c b/util/cbfstool/common.c
index 8db2d8cfe3..9227337c57 100644
--- a/util/cbfstool/common.c
+++ b/util/cbfstool/common.c
@@ -31,6 +31,8 @@ void *loadfile(const char *filename, uint32_t * romsize_p, void *content,
int place)
{
FILE *file = fopen(filename, "rb");
+ if (file == NULL)
+ return NULL;
fseek(file, 0, SEEK_END);
*romsize_p = ftell(file);
fseek(file, 0, SEEK_SET);
@@ -65,6 +67,8 @@ void recalculate_rom_geometry(void *romarea)
void *loadrom(const char *filename)
{
void *romarea = loadfile(filename, &romsize, 0, SEEK_SET);
+ if (romarea == NULL)
+ return NULL;
recalculate_rom_geometry(romarea);
return romarea;
}