diff mbox

[v2] rbd: Fix leaks in rbd_start_aio() error path

Message ID 1401977966-11664-1-git-send-email-kwolf@redhat.com
State New
Headers show

Commit Message

Kevin Wolf June 5, 2014, 2:19 p.m. UTC
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/rbd.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Benoît Canet June 5, 2014, 2:40 p.m. UTC | #1
The Thursday 05 Jun 2014 à 16:19:26 (+0200), Kevin Wolf wrote :
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block/rbd.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/block/rbd.c b/block/rbd.c
> index 09af484..898fcfe 100644
> --- a/block/rbd.c
> +++ b/block/rbd.c
> @@ -684,13 +684,16 @@ static BlockDriverAIOCB *rbd_start_aio(BlockDriverState *bs,
>      }
>  
>      if (r < 0) {
> -        goto failed;
> +        goto failed_completion;
>      }
>  
>      return &acb->common;
>  
> +failed_completion:
> +    rbd_aio_release(c);
>  failed:
>      g_free(rcb);
> +    qemu_vfree(acb->bounce);
>      qemu_aio_release(acb);
>      return NULL;
>  }
> -- 
> 1.8.3.1
> 
Reviewed-by: Benoit Canet <benoit@irqsave.net>
Josh Durgin June 5, 2014, 10:02 p.m. UTC | #2
On 06/05/2014 07:19 AM, Kevin Wolf wrote:
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>   block/rbd.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/block/rbd.c b/block/rbd.c
> index 09af484..898fcfe 100644
> --- a/block/rbd.c
> +++ b/block/rbd.c
> @@ -684,13 +684,16 @@ static BlockDriverAIOCB *rbd_start_aio(BlockDriverState *bs,
>       }
>
>       if (r < 0) {
> -        goto failed;
> +        goto failed_completion;
>       }
>
>       return &acb->common;
>
> +failed_completion:
> +    rbd_aio_release(c);
>   failed:
>       g_free(rcb);
> +    qemu_vfree(acb->bounce);
>       qemu_aio_release(acb);
>       return NULL;
>   }
>

Reviewed-by: Josh Durgin <josh.durgin@inktank.com>

FWIW this error path can only happen in certain combinations of odd
circumstances, including specific forms of disk corruption of certain
objects in concert with other factors, so it's quite unlikely to occur
in practice.
Stefan Hajnoczi June 9, 2014, 1:28 p.m. UTC | #3
On Thu, Jun 05, 2014 at 04:19:26PM +0200, Kevin Wolf wrote:
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block/rbd.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

(It seems I forgot to reply last week when I merged this.)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan
diff mbox

Patch

diff --git a/block/rbd.c b/block/rbd.c
index 09af484..898fcfe 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -684,13 +684,16 @@  static BlockDriverAIOCB *rbd_start_aio(BlockDriverState *bs,
     }
 
     if (r < 0) {
-        goto failed;
+        goto failed_completion;
     }
 
     return &acb->common;
 
+failed_completion:
+    rbd_aio_release(c);
 failed:
     g_free(rcb);
+    qemu_vfree(acb->bounce);
     qemu_aio_release(acb);
     return NULL;
 }