diff mbox

qemu-io: Fix memory leak in 'aio_write -z'

Message ID 1462788216-14009-1-git-send-email-kwolf@redhat.com
State New, archived
Headers show

Commit Message

Kevin Wolf May 9, 2016, 10:03 a.m. UTC
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 qemu-io-cmds.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Eric Blake May 9, 2016, 2:47 p.m. UTC | #1
On 05/09/2016 04:03 AM, Kevin Wolf wrote:
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  qemu-io-cmds.c | 1 +
>  1 file changed, 1 insertion(+)

Reviewed-by: Eric Blake <eblake@redhat.com>

Perhaps it would be easier to convert all the mid-function returns into
'goto cleanup', so that we don't have to repeat the cleanups everywhere,
but that's more invasive.

> 
> diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
> index e34f777..41580b5 100644
> --- a/qemu-io-cmds.c
> +++ b/qemu-io-cmds.c
> @@ -1699,6 +1699,7 @@ static int aio_write_f(BlockBackend *blk, int argc, char **argv)
>          int64_t count = cvtnum(argv[optind]);
>          if (count < 0) {
>              print_cvtnum_err(count, argv[optind]);
> +            g_free(ctx);
>              return 0;
>          }
>  
>
diff mbox

Patch

diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
index e34f777..41580b5 100644
--- a/qemu-io-cmds.c
+++ b/qemu-io-cmds.c
@@ -1699,6 +1699,7 @@  static int aio_write_f(BlockBackend *blk, int argc, char **argv)
         int64_t count = cvtnum(argv[optind]);
         if (count < 0) {
             print_cvtnum_err(count, argv[optind]);
+            g_free(ctx);
             return 0;
         }