From patchwork Wed Jul 19 08:36:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 9850721 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5698260388 for ; Wed, 19 Jul 2017 08:37:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 425A026E4A for ; Wed, 19 Jul 2017 08:37:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 37402285F0; Wed, 19 Jul 2017 08:37:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF56626E4A for ; Wed, 19 Jul 2017 08:37:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752887AbdGSIhB (ORCPT ); Wed, 19 Jul 2017 04:37:01 -0400 Received: from mx2.suse.de ([195.135.220.15]:56169 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752070AbdGSIhA (ORCPT ); Wed, 19 Jul 2017 04:37:00 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A1B75AC03; Wed, 19 Jul 2017 08:36:58 +0000 (UTC) Date: Wed, 19 Jul 2017 10:36:54 +0200 From: Johannes Thumshirn To: Jason L Tibbitts III , Doug Gilbert Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, dvyukov@google.com, hare@suse.com, hch@lst.de, martin.petersen@oracle.com Subject: Re: [REGRESSION] 28676d869bbb (scsi: sg: check for valid direction before starting the request) breaks mtx tape library control Message-ID: <20170719083654.GE4151@linux-x5ow.site> References: <20170718073747.GD4875@linux-x5ow.site> <20170719070335.GC4151@linux-x5ow.site> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Wed, Jul 19, 2017 at 03:13:34AM -0500, Jason L Tibbitts III wrote: > [ 46.304530] sg_is_valid_dxfer: dxfer_direction: -2, dxfer_len: 0 Ahh now I see the -2 (SG_DXFER_TO_DEV) is the crucial point here. It is 0 in your case. This would "fix" it but I'm not generally sure it is _the_ solution: Doug, what are the rules for SG_DXFER_TO_{FROM_}DEV? Apparently we can't be sure len > 0, can we rely on dxferp being present? Thanks, Johannes diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 1e82d4128a84..b421ec81d775 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -764,7 +764,7 @@ static bool sg_is_valid_dxfer(sg_io_hdr_t *hp) return true; case SG_DXFER_TO_DEV: case SG_DXFER_TO_FROM_DEV: - if (!hp->dxferp || hp->dxfer_len == 0) + if (!hp->dxferp) return false; return true; case SG_DXFER_UNKNOWN: