diff mbox

blockdev: Fix wrong usage of QDECREF causing snapshoted quorum to crash on close.

Message ID 1392308553-9886-2-git-send-email-benoit.canet@irqsave.net
State New
Headers show

Commit Message

Benoît Canet Feb. 13, 2014, 4:22 p.m. UTC
As bdrv_open() documentation states:
"The reference to the QDict belongs to the block layer
 * after the call (even on failure), so if the caller intends to reuse the
 * dictionary, it needs to use QINCREF() before calling bdrv_open."

the optional options dict will not be reused after bdrv_open() and should
belong to the block layer so remove the extra QDECREF(options).

Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 blockdev.c | 2 --
 1 file changed, 2 deletions(-)

Comments

Kevin Wolf Feb. 14, 2014, 10:01 a.m. UTC | #1
Am 13.02.2014 um 17:22 hat Benoît Canet geschrieben:
> As bdrv_open() documentation states:
> "The reference to the QDict belongs to the block layer
>  * after the call (even on failure), so if the caller intends to reuse the
>  * dictionary, it needs to use QINCREF() before calling bdrv_open."
> 
> the optional options dict will not be reused after bdrv_open() and should
> belong to the block layer so remove the extra QDECREF(options).
> 
> Signed-off-by: Benoit Canet <benoit@irqsave.net>

Ouch, yes. Sorry for not catching this in the review.

Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Stefan Hajnoczi Feb. 14, 2014, 3:30 p.m. UTC | #2
On Thu, Feb 13, 2014 at 05:22:33PM +0100, Benoît Canet wrote:
> As bdrv_open() documentation states:
> "The reference to the QDict belongs to the block layer
>  * after the call (even on failure), so if the caller intends to reuse the
>  * dictionary, it needs to use QINCREF() before calling bdrv_open."
> 
> the optional options dict will not be reused after bdrv_open() and should
> belong to the block layer so remove the extra QDECREF(options).
> 
> Signed-off-by: Benoit Canet <benoit@irqsave.net>
> ---
>  blockdev.c | 2 --
>  1 file changed, 2 deletions(-)

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

Stefan
diff mbox

Patch

diff --git a/blockdev.c b/blockdev.c
index 5cd50f3..7fbce6c 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1316,8 +1316,6 @@  static void external_snapshot_prepare(BlkTransactionState *common,
     if (ret != 0) {
         error_propagate(errp, local_err);
     }
-
-    QDECREF(options);
 }
 
 static void external_snapshot_commit(BlkTransactionState *common)