diff mbox

[v7,02/24] blockjob: Call bdrv_unref() on creation error

Message ID 1447108773-6836-3-git-send-email-mreitz@redhat.com
State New
Headers show

Commit Message

Max Reitz Nov. 9, 2015, 10:39 p.m. UTC
If block_job_create() fails, it should release its reference to the
job's BDS. Normally, this is done in the callback provided by the
caller, but that callback will not be invoked if the block job failed to
be created.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
---
 blockjob.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Fam Zheng Nov. 12, 2015, 6:16 a.m. UTC | #1
On Mon, 11/09 23:39, Max Reitz wrote:
> If block_job_create() fails, it should release its reference to the
> job's BDS. Normally, this is done in the callback provided by the
> caller, but that callback will not be invoked if the block job failed to
> be created.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> Reviewed-by: Alberto Garcia <berto@igalia.com>
> Reviewed-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  blockjob.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/blockjob.c b/blockjob.c
> index c02fe59..0886a4a 100644
> --- a/blockjob.c
> +++ b/blockjob.c
> @@ -70,6 +70,7 @@ void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs,
>          if (local_err) {
>              block_job_release(bs);
>              error_propagate(errp, local_err);
> +            bdrv_unref(bs);
>              return NULL;
>          }
>      }
> -- 
> 2.6.2
> 
> 

Reviewed-by: Fam Zheng <famz@redhat.com>
Kevin Wolf Nov. 18, 2015, 3:24 p.m. UTC | #2
Am 09.11.2015 um 23:39 hat Max Reitz geschrieben:
> If block_job_create() fails, it should release its reference to the
> job's BDS. Normally, this is done in the callback provided by the
> caller, but that callback will not be invoked if the block job failed to
> be created.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> Reviewed-by: Alberto Garcia <berto@igalia.com>
> Reviewed-by: Kevin Wolf <kwolf@redhat.com>

Commit 18930ba3 already fixed this. Now adding another bdrv_unref()
would be wrong, so I guess we have to simply drop the patch.

NACK
diff mbox

Patch

diff --git a/blockjob.c b/blockjob.c
index c02fe59..0886a4a 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -70,6 +70,7 @@  void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs,
         if (local_err) {
             block_job_release(bs);
             error_propagate(errp, local_err);
+            bdrv_unref(bs);
             return NULL;
         }
     }