]> git.proxmox.com Git - qemu.git/commitdiff
block: Fix multiwrite error handling
authorKevin Wolf <kwolf@redhat.com>
Thu, 1 Apr 2010 20:48:44 +0000 (22:48 +0200)
committerAurelien Jarno <aurelien@aurel32.net>
Fri, 9 Apr 2010 22:14:23 +0000 (00:14 +0200)
When two requests of the same multiwrite batch fail, the callback of all
requests in that batch were called twice. This could have any kind of nasty
effects, in my case it lead to use after free and eventually a segfault.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
block.c

diff --git a/block.c b/block.c
index e891544dd1e3cf1daa7409cbb064b477f3ef6011..06ed08ad88b499ce9c0c51c66008d69983ba4ee2 100644 (file)
--- a/block.c
+++ b/block.c
@@ -1740,7 +1740,7 @@ static void multiwrite_cb(void *opaque, int ret)
 {
     MultiwriteCB *mcb = opaque;
 
-    if (ret < 0) {
+    if (ret < 0 && !mcb->error) {
         mcb->error = ret;
         multiwrite_user_cb(mcb);
     }