From patchwork Thu Apr 1 20:48:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 49244 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4FD88B7D14 for ; Fri, 2 Apr 2010 07:52:46 +1100 (EST) Received: from localhost ([127.0.0.1]:43959 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NxRNb-00072z-Dv for incoming@patchwork.ozlabs.org; Thu, 01 Apr 2010 16:52:43 -0400 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 Received: from localhost.localdomain (vpn1-7-117.ams2.redhat.com [10.36.7.117]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o31KnGvG022426; Thu, 1 Apr 2010 16:49:17 -0400 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Thu, 1 Apr 2010 22:48:44 +0200 Message-Id: <1270154924-10400-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: kwolf@redhat.com Subject: [Qemu-devel] [PATCH] block: Fix multiwrite error handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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); }