diff mbox

[1/2] qcow2: Fix memory leak in copy_sectors()

Message ID 1401315594-12662-2-git-send-email-mreitz@redhat.com
State New
Headers show

Commit Message

Max Reitz May 28, 2014, 10:19 p.m. UTC
If bs->drv is NULL, iov.iov_base should not be leaked.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block/qcow2-cluster.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Eric Blake May 28, 2014, 10:33 p.m. UTC | #1
On 05/28/2014 04:19 PM, Max Reitz wrote:
> If bs->drv is NULL, iov.iov_base should not be leaked.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  block/qcow2-cluster.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

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

> 
> diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
> index 33e6826..d391c5a 100644
> --- a/block/qcow2-cluster.c
> +++ b/block/qcow2-cluster.c
> @@ -387,7 +387,8 @@ static int coroutine_fn copy_sectors(BlockDriverState *bs,
>      BLKDBG_EVENT(bs->file, BLKDBG_COW_READ);
>  
>      if (!bs->drv) {
> -        return -ENOMEDIUM;
> +        ret = -ENOMEDIUM;
> +        goto out;
>      }
>  
>      /* Call .bdrv_co_readv() directly instead of using the public block-layer
>
Kevin Wolf May 30, 2014, 11:40 a.m. UTC | #2
Am 29.05.2014 um 00:19 hat Max Reitz geschrieben:
> If bs->drv is NULL, iov.iov_base should not be leaked.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>

Funny how such things go unnoticed for months and then three people fix
it independently in the same week. Anyway, I won: commit bd604369 ;-)

Kevin
Max Reitz May 30, 2014, 4:26 p.m. UTC | #3
On 30.05.2014 13:40, Kevin Wolf wrote:
> Am 29.05.2014 um 00:19 hat Max Reitz geschrieben:
>> If bs->drv is NULL, iov.iov_base should not be leaked.
>>
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
> Funny how such things go unnoticed for months and then three people fix
> it independently in the same week. Anyway, I won: commit bd604369 ;-)

Well, I noticed it while reviewing your series, so it may be not too 
coincidental. ;-)

Max
diff mbox

Patch

diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index 33e6826..d391c5a 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -387,7 +387,8 @@  static int coroutine_fn copy_sectors(BlockDriverState *bs,
     BLKDBG_EVENT(bs->file, BLKDBG_COW_READ);
 
     if (!bs->drv) {
-        return -ENOMEDIUM;
+        ret = -ENOMEDIUM;
+        goto out;
     }
 
     /* Call .bdrv_co_readv() directly instead of using the public block-layer