[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 20/22] qemu-io: Don't leak pattern file in error path
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 20/22] qemu-io: Don't leak pattern file in error path |
Date: |
Thu, 12 Sep 2019 15:46:02 +0200 |
qemu_io_alloc_from_file() needs to close the pattern file even if some
error occurred.
Setting f = NULL in the success path and checking it for NULL in the
error path isn't strictly necessary at this point, but let's do it
anyway in case someone later adds a 'goto error' after closing the file.
Coverity: CID 1405303
Fixes: 4d731510d34f280ed45a6de621d016f67a49ea48
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Reviewed-by: Stefano Garzarella <address@hidden>
---
qemu-io-cmds.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
index d46fa166d3..349256a5fe 100644
--- a/qemu-io-cmds.c
+++ b/qemu-io-cmds.c
@@ -401,6 +401,7 @@ static void *qemu_io_alloc_from_file(BlockBackend *blk,
size_t len,
}
fclose(f);
+ f = NULL;
if (len > pattern_len) {
len -= pattern_len;
@@ -420,6 +421,9 @@ static void *qemu_io_alloc_from_file(BlockBackend *blk,
size_t len,
error:
qemu_io_free(buf_origin);
+ if (f) {
+ fclose(f);
+ }
return NULL;
}
--
2.20.1
- [Qemu-block] [PULL 09/22] iotests: Restrict file Python tests to file, (continued)
- [Qemu-block] [PULL 09/22] iotests: Restrict file Python tests to file, Kevin Wolf, 2019/09/12
- [Qemu-block] [PULL 11/22] iotests: Test blockdev-create for vpc, Kevin Wolf, 2019/09/12
- [Qemu-block] [PULL 12/22] iotests: skip 232 when run tests as root, Kevin Wolf, 2019/09/12
- [Qemu-block] [PULL 13/22] block/nfs: add support for nfs_umount, Kevin Wolf, 2019/09/12
- [Qemu-block] [PULL 15/22] iotests: exclude killed processes from running under Valgrind, Kevin Wolf, 2019/09/12
- [Qemu-block] [PULL 16/22] iotests: Add casenotrun report to bash tests, Kevin Wolf, 2019/09/12
- [Qemu-block] [PULL 14/22] iotests: allow Valgrind checking all QEMU processes, Kevin Wolf, 2019/09/12
- [Qemu-block] [PULL 17/22] iotests: Valgrind fails with nonexistent directory, Kevin Wolf, 2019/09/12
- [Qemu-block] [PULL 18/22] iotests: extended timeout under Valgrind, Kevin Wolf, 2019/09/12
- [Qemu-block] [PULL 19/22] iotests: extend sleeping time under Valgrind, Kevin Wolf, 2019/09/12
- [Qemu-block] [PULL 20/22] qemu-io: Don't leak pattern file in error path,
Kevin Wolf <=
- [Qemu-block] [PULL 22/22] qcow2: Stop overwriting compressed clusters one by one, Kevin Wolf, 2019/09/12
- [Qemu-block] [PULL 21/22] block/create: Do not abort if a block driver is not available, Kevin Wolf, 2019/09/12
- Re: [Qemu-block] [PULL 00/22] Block layer patches, Peter Maydell, 2019/09/13