Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] zlib: fix resource leak when gzdirect failed
@ 2020-11-30  6:41 qiuguorui1
  2020-11-30 16:37 ` Simon Horman
  0 siblings, 1 reply; 2+ messages in thread
From: qiuguorui1 @ 2020-11-30  6:41 UTC (permalink / raw)
  To: kexec, yszhou4tech; +Cc: qiuguorui1, horms, leeyou.li, zengweilin

In function zlib_decompress_file, when gzdirect(fp) fails,
we should gzclose fp before return.

Fixes: d606837b56d46 ("Fix zlib/lzma decompression.")
Signed-off-by: qiuguorui1 <qiuguorui1@huawei.com>
---
 kexec/zlib.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kexec/zlib.c b/kexec/zlib.c
index 9bc340d..3ed6bd6 100644
--- a/kexec/zlib.c
+++ b/kexec/zlib.c
@@ -60,7 +60,7 @@ char *zlib_decompress_file(const char *filename, off_t *r_size)
 	gzFile fp;
 	int errnum;
 	const char *msg;
-	char *buf;
+	char *buf = NULL;
 	off_t size = 0, allocated;
 	ssize_t result;
 
@@ -78,7 +78,7 @@ char *zlib_decompress_file(const char *filename, off_t *r_size)
 	}
 	if (gzdirect(fp)) {
 		/* It's not in gzip format */
-		return NULL;
+		goto fail;
 	}
 	allocated = 65536;
 	buf = xmalloc(allocated);
-- 
2.12.3


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] zlib: fix resource leak when gzdirect failed
  2020-11-30  6:41 [PATCH] zlib: fix resource leak when gzdirect failed qiuguorui1
@ 2020-11-30 16:37 ` Simon Horman
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2020-11-30 16:37 UTC (permalink / raw)
  To: qiuguorui1; +Cc: yszhou4tech, leeyou.li, kexec, zengweilin

On Mon, Nov 30, 2020 at 02:41:25PM +0800, qiuguorui1 wrote:
> In function zlib_decompress_file, when gzdirect(fp) fails,
> we should gzclose fp before return.
> 
> Fixes: d606837b56d46 ("Fix zlib/lzma decompression.")
> Signed-off-by: qiuguorui1 <qiuguorui1@huawei.com>

Thanks, applied.

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-30 16:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-30  6:41 [PATCH] zlib: fix resource leak when gzdirect failed qiuguorui1
2020-11-30 16:37 ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox