From patchwork Wed Jan 29 17:47:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 315169 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8B14C2C0804 for ; Thu, 30 Jan 2014 04:48:25 +1100 (EST) Received: from localhost ([::1]:44251 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8ZFO-0003oE-0J for incoming@patchwork.ozlabs.org; Wed, 29 Jan 2014 12:48:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57331) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8ZEq-0003eU-OP for qemu-devel@nongnu.org; Wed, 29 Jan 2014 12:47:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8ZEk-0000Tv-B2 for qemu-devel@nongnu.org; Wed, 29 Jan 2014 12:47:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45163) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8ZEk-0000TN-34 for qemu-devel@nongnu.org; Wed, 29 Jan 2014 12:47:42 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0THlfn4012480 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 29 Jan 2014 12:47:41 -0500 Received: from blackfin.pond.sub.org (ovpn-116-48.ams2.redhat.com [10.36.116.48]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s0THld6u018471 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 29 Jan 2014 12:47:41 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 307E0200CF; Wed, 29 Jan 2014 18:47:39 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 29 Jan 2014 18:47:39 +0100 Message-Id: <1391017659-5506-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: pbonzini@redhat.com Subject: [Qemu-devel] [PATCH] scsi-bus: Fix transfer length for VERIFY with BYTCHK=11b 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 The transfer length depends on field BYTCHK, which is encoded in byte 1, bits 1..2. However, the guard for for case BYTCHK=11b doesn't work, and we get case 01b instead. Fix it. Note that since emulated scsi-hd fails the command outright, it takes SCSI passthrough of a device that actually implements VERIFY with BYTCHK=11b to make the bug bite. Screwed up in commit d12ad44. Spotted by Coverity. Signed-off-by: Markus Armbruster --- hw/scsi/scsi-bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index 50b89ad..285a58b 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -909,7 +909,7 @@ static int scsi_req_length(SCSICommand *cmd, SCSIDevice *dev, uint8_t *buf) case VERIFY_16: if ((buf[1] & 2) == 0) { cmd->xfer = 0; - } else if ((buf[1] & 4) == 1) { + } else if ((buf[1] & 4) != 0) { cmd->xfer = 1; } cmd->xfer *= dev->blocksize;