* [Qemu-devel] [PATCH] qemu-io: Don't leak pattern file in error path
@ 2019-09-10 7:09 Kevin Wolf
2019-09-10 7:45 ` Max Reitz
2019-09-10 9:33 ` [Qemu-devel] [Qemu-block] " Stefano Garzarella
0 siblings, 2 replies; 3+ messages in thread
From: Kevin Wolf @ 2019-09-10 7:09 UTC (permalink / raw)
To: qemu-block; +Cc: kwolf, dplotnikov, qemu-devel, mreitz
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 <kwolf@redhat.com>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu-io: Don't leak pattern file in error path
2019-09-10 7:09 [Qemu-devel] [PATCH] qemu-io: Don't leak pattern file in error path Kevin Wolf
@ 2019-09-10 7:45 ` Max Reitz
2019-09-10 9:33 ` [Qemu-devel] [Qemu-block] " Stefano Garzarella
1 sibling, 0 replies; 3+ messages in thread
From: Max Reitz @ 2019-09-10 7:45 UTC (permalink / raw)
To: Kevin Wolf, qemu-block; +Cc: dplotnikov, qemu-devel
[-- Attachment #1.1: Type: text/plain, Size: 600 bytes --]
On 10.09.19 09:09, Kevin Wolf wrote:
> 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 <kwolf@redhat.com>
> ---
> qemu-io-cmds.c | 4 ++++
> 1 file changed, 4 insertions(+)
Reviewed-by: Max Reitz <mreitz@redhat.com>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [Qemu-block] [PATCH] qemu-io: Don't leak pattern file in error path
2019-09-10 7:09 [Qemu-devel] [PATCH] qemu-io: Don't leak pattern file in error path Kevin Wolf
2019-09-10 7:45 ` Max Reitz
@ 2019-09-10 9:33 ` Stefano Garzarella
1 sibling, 0 replies; 3+ messages in thread
From: Stefano Garzarella @ 2019-09-10 9:33 UTC (permalink / raw)
To: Kevin Wolf; +Cc: dplotnikov, qemu-devel, qemu-block, mreitz
On Tue, Sep 10, 2019 at 09:09:49AM +0200, Kevin Wolf wrote:
> 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 <kwolf@redhat.com>
> ---
> qemu-io-cmds.c | 4 ++++
> 1 file changed, 4 insertions(+)
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-09-10 9:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-10 7:09 [Qemu-devel] [PATCH] qemu-io: Don't leak pattern file in error path Kevin Wolf
2019-09-10 7:45 ` Max Reitz
2019-09-10 9:33 ` [Qemu-devel] [Qemu-block] " Stefano Garzarella
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.