Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NxRKM-00022z-Un for qemu-devel@nongnu.org; Thu, 01 Apr 2010 16:49:23 -0400 Received: from [140.186.70.92] (port=54268 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NxRKL-000202-Lh for qemu-devel@nongnu.org; Thu, 01 Apr 2010 16:49:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NxRKK-00073K-EP for qemu-devel@nongnu.org; Thu, 01 Apr 2010 16:49:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55964) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NxRKK-000739-72 for qemu-devel@nongnu.org; Thu, 01 Apr 2010 16:49:20 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o31KnI2L019505 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 1 Apr 2010 16:49:19 -0400 From: Kevin Wolf Date: Thu, 1 Apr 2010 22:48:44 +0200 Message-Id: <1270154924-10400-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH] block: Fix multiwrite error handling List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com 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 --- block.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/block.c b/block.c index 31610af..1c36e91 100644 --- a/block.c +++ b/block.c @@ -1734,7 +1734,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); } -- 1.6.6.1