Patchwork [26/26] block: Free iovec arrays allocated by multiwrite_merge()

login
register
mail settings
Submitter Kevin Wolf
Date April 23, 2010, 3:30 p.m.
Message ID <1272036658-26776-27-git-send-email-kwolf@redhat.com>
Download mbox | patch
Permalink /patch/50845/
State New
Headers show

Comments

Kevin Wolf - April 23, 2010, 3:30 p.m.
From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>

A new iovec array is allocated when creating a merged write request.
This patch ensures that the iovec array is deleted in addition to its
qiov owner.

Reported-by: Leszek Urbanski <tygrys@moo.pl>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
Ryan Harper - April 23, 2010, 8:22 p.m.
* Kevin Wolf <kwolf@redhat.com> [2010-04-23 11:29]:
> From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
> 
> A new iovec array is allocated when creating a merged write request.
> This patch ensures that the iovec array is deleted in addition to its
> qiov owner.
> 

Submit for [STABLE] ?

> Reported-by: Leszek Urbanski <tygrys@moo.pl>
> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/block.c b/block.c
> index 12cf434..7974215 100644
> --- a/block.c
> +++ b/block.c
> @@ -1739,6 +1739,9 @@ static void multiwrite_user_cb(MultiwriteCB *mcb)
> 
>      for (i = 0; i < mcb->num_callbacks; i++) {
>          mcb->callbacks[i].cb(mcb->callbacks[i].opaque, mcb->error);
> +        if (mcb->callbacks[i].free_qiov) {
> +            qemu_iovec_destroy(mcb->callbacks[i].free_qiov);
> +        }
>          qemu_free(mcb->callbacks[i].free_qiov);
>          qemu_vfree(mcb->callbacks[i].free_buf);
>      }
> -- 
> 1.6.6.1
> 
>
Aurelien Jarno - April 25, 2010, 1:42 a.m.
On Fri, Apr 23, 2010 at 03:22:14PM -0500, Ryan Harper wrote:
> * Kevin Wolf <kwolf@redhat.com> [2010-04-23 11:29]:
> > From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
> > 
> > A new iovec array is allocated when creating a merged write request.
> > This patch ensures that the iovec array is deleted in addition to its
> > qiov owner.
> > 
> 
> Submit for [STABLE] ?
> 

I have just cherry-picked it into stable

Patch

diff --git a/block.c b/block.c
index 12cf434..7974215 100644
--- a/block.c
+++ b/block.c
@@ -1739,6 +1739,9 @@  static void multiwrite_user_cb(MultiwriteCB *mcb)
 
     for (i = 0; i < mcb->num_callbacks; i++) {
         mcb->callbacks[i].cb(mcb->callbacks[i].opaque, mcb->error);
+        if (mcb->callbacks[i].free_qiov) {
+            qemu_iovec_destroy(mcb->callbacks[i].free_qiov);
+        }
         qemu_free(mcb->callbacks[i].free_qiov);
         qemu_vfree(mcb->callbacks[i].free_buf);
     }