aboutsummaryrefslogtreecommitdiff
path: root/libflash
diff options
context:
space:
mode:
authorStewart Smith <stewart@linux.vnet.ibm.com>2015-11-17 15:16:44 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-11-17 15:16:44 +1100
commit8041e51dc29959c7c2fff6aa93259914a7097397 (patch)
treeea47cb8e78e3a447e0f27b7c78ad801a22015ef8 /libflash
parent8dcabbba7ead5061bec7a878512d300180a48572 (diff)
downloadskiboot-8041e51dc29959c7c2fff6aa93259914a7097397.zip
skiboot-8041e51dc29959c7c2fff6aa93259914a7097397.tar.gz
skiboot-8041e51dc29959c7c2fff6aa93259914a7097397.tar.bz2
libflash: fix resource leaks on errors in ffs_open_image
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'libflash')
-rw-r--r--libflash/libffs.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libflash/libffs.c b/libflash/libffs.c
index 3010a61..5563e52 100644
--- a/libflash/libffs.c
+++ b/libflash/libffs.c
@@ -234,12 +234,16 @@ int ffs_open_image(int fd, uint32_t size, uint32_t toc_offset,
/* Read the cached map */
rc = lseek(fd, toc_offset, SEEK_SET);
- if (rc < 0)
+ if (rc < 0) {
+ free(f->cache);
+ free(f);
return FLASH_ERR_PARM_ERROR;
+ }
rc = read(fd, f->cache, f->cached_size);
if (rc != f->cached_size) {
FL_ERR("FFS: Error %d reading flash partition map\n", rc);
+ free(f->cache);
free(f);
return FLASH_ERR_BAD_READ;
}