From patchwork Thu May 26 10:56:28 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 97537 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A5323B6EDF for ; Thu, 26 May 2011 20:57:30 +1000 (EST) Received: from localhost ([::1]:34666 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPYFq-00028M-9u for incoming@patchwork.ozlabs.org; Thu, 26 May 2011 06:57:26 -0400 Received: from eggs.gnu.org ([140.186.70.92]:55912) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPYFU-00023g-2N for qemu-devel@nongnu.org; Thu, 26 May 2011 06:57:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QPYFQ-0003Uk-KX for qemu-devel@nongnu.org; Thu, 26 May 2011 06:57:04 -0400 Received: from mail-ww0-f41.google.com ([74.125.82.41]:46154) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPYFQ-0003UA-Bv for qemu-devel@nongnu.org; Thu, 26 May 2011 06:57:00 -0400 Received: by wwi18 with SMTP id 18so4306691wwi.4 for ; Thu, 26 May 2011 03:56:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:from:to:cc:subject:date:message-id :x-mailer:in-reply-to:references; bh=+eIJWaLdETExfw0fr9/Zcyn83oZKlhtY3UjS+gUdEA0=; b=QCTPpM1yWTPGwyZ9U09qvHFYwOH3PpHjnPkWbYjn1RM5iq2qHz5VpM+ba/XR92KaKj bAifE9GIhU5qnB7FnrApJY13QeFDru4+rHEQZS5uGqPMb26Yiqs0Oi3Yww3Ig41USLD+ 1hKZGdGxz2E/JGXSxVO3ZYE0qGNLNo3tkUE1o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; b=PqBNoC5AvW0/vBAfAAZrA+heqQ4PyhvDoldlDtXXv4OB7SEgEqvNh3nPZp9r9ZOU4F mE51DUegTbHPXWjI9IGZZ5NS43s+pZPfL3utrmezx6pjkh8XJIEw6HUkJ6Y8Zq836up9 tZoh5rqqLT14zeVHHHR9H4MstmUSDb5yS1esQ= Received: by 10.216.67.15 with SMTP id i15mr5727908wed.32.1306407419449; Thu, 26 May 2011 03:56:59 -0700 (PDT) Received: from localhost.localdomain (93-34-184-88.ip51.fastwebnet.it [93.34.184.88]) by mx.google.com with ESMTPS id k16sm293060wed.8.2011.05.26.03.56.58 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 26 May 2011 03:56:58 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 26 May 2011 12:56:28 +0200 Message-Id: <1306407411-4290-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.4.4 In-Reply-To: <1306407411-4290-1-git-send-email-pbonzini@redhat.com> References: <1306407411-4290-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.82.41 Cc: David Gibson Subject: [Qemu-devel] [PATCH v5 02/25] scsi-generic: Remove bogus double complete X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org scsi-generic scsi_read_complete() should not -both- call the client complete callback with SCSI_REASON_DATA -and- call scsi_command_complete(). The former will cause the client to queue a new read or write request, while the later will free the request data structure, thus causing the new read or write request to use a freed/stale structure when it completes. This patch fixes the bug, fixing a crash with scsi-generic & RHEL5.5 installer. Cc: Benjamin Herrenschmidt Cc: David Gibson Signed-off-by: Paolo Bonzini Reviewed-by: Christoph Hellwig --- hw/scsi-generic.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c index 9be1cca..102f1da 100644 --- a/hw/scsi-generic.c +++ b/hw/scsi-generic.c @@ -172,9 +172,11 @@ static void scsi_read_complete(void * opaque, int ret) DPRINTF("Data ready tag=0x%x len=%d\n", r->req.tag, len); r->len = -1; - r->req.bus->complete(r->req.bus, SCSI_REASON_DATA, r->req.tag, len); - if (len == 0) + if (len == 0) { scsi_command_complete(r, 0); + } else { + r->req.bus->complete(r->req.bus, SCSI_REASON_DATA, r->req.tag, len); + } } /* Read more data from scsi device into buffer. */