summaryrefslogtreecommitdiff
path: root/kexec
diff options
context:
space:
mode:
authorKai Song <songkai01@inspur.com>2021-09-29 16:11:57 +0800
committerSimon Horman <horms@verge.net.au>2021-10-05 10:29:17 +0200
commita4d49e8b58bbf6c3572f363d33fe2db7dc73b7bc (patch)
tree7e6a5b32d642ecf226af910bf3682d836afaada4 /kexec
parentbcee4f232e443053e1f6b9297716cad2488f7322 (diff)
downloadkexec-tools-a4d49e8b58bbf6c3572f363d33fe2db7dc73b7bc.tar.gz
Add some necessary free() calls
free should be called before the function exit abnormally. Signed-off-by: Kai Song <songkai01@inspur.com> Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'kexec')
-rw-r--r--kexec/kexec-uImage.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/kexec/kexec-uImage.c b/kexec/kexec-uImage.c
index eeee4be..016be10 100644
--- a/kexec/kexec-uImage.c
+++ b/kexec/kexec-uImage.c
@@ -157,12 +157,15 @@ static int uImage_gz_load(const char *buf, off_t len,
skip = 10;
/* check GZ magic */
- if (buf[0] != 0x1f || buf[1] != 0x8b)
+ if (buf[0] != 0x1f || buf[1] != 0x8b) {
+ free(uncomp_buf);
return -1;
+ }
flags = buf[3];
if (buf[2] != Z_DEFLATED || (flags & RESERVED) != 0) {
puts ("Error: Bad gzipped data\n");
+ free(uncomp_buf);
return -1;
}
@@ -187,8 +190,10 @@ static int uImage_gz_load(const char *buf, off_t len,
/* - activates parsing gz headers */
ret = inflateInit2(&strm, -MAX_WBITS);
- if (ret != Z_OK)
+ if (ret != Z_OK) {
+ free(uncomp_buf);
return -1;
+ }
strm.next_out = uncomp_buf;
strm.avail_out = mem_alloc;
@@ -214,6 +219,7 @@ static int uImage_gz_load(const char *buf, off_t len,
strm.next_out = uncomp_buf + mem_alloc - inc_buf;
strm.avail_out = inc_buf;
} else {
+ free(uncomp_buf);
printf("Error during decompression %d\n", ret);
return -1;
}