Received: by 10.192.165.156 with SMTP id m28csp1132664imm; Wed, 11 Apr 2018 13:03:13 -0700 (PDT) X-Google-Smtp-Source: AIpwx48ZAEuHcUEs3eEN5UT7slWZvkMZrWouOkgvOZ/aJFzjl4VeXzRvgAJuuw064LDgJR64Kw0G X-Received: by 10.99.43.70 with SMTP id r67mr4529376pgr.422.1523476993004; Wed, 11 Apr 2018 13:03:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523476992; cv=none; d=google.com; s=arc-20160816; b=XuqPpfaW4AecKhQ25QvW0bPq8MmRT7+dSCBDYs/Qr6x+OvaLGLzW5FRGUAo2+kQlRv eY2wwBT0aIqlIQDf6zLo00Ri6FjJb/s3Lr1CXCGN1kq4GVnO+b1AJaFisesqJCmh0nNb TjcENog+HsnHsM6LOipiBPpioww3/fsKSGJ/IKHjw/b8Bwg6FB+KjwX40rqR5ZTNilvP 0vfW6zQjNPuo6gnahWxEyX1RGbKiZKUwOi/q+bSfssQ7Ky9RUyge2gDoLlaxNlQF118d YXInKHZACtj4vz8gPIPMhEPwQVMaKMhq4b3NLe86C6qpUX5W7JYoWIngmgALq1OMK6m8 VrUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=w+zSpbJSwnB9t2rnmZIQV9+ngilIikBFT2QZVu9xPnI=; b=Qtq5AROXTeqLoo7ru1sJcty/NZ8XXEIq82EBbxaYR/4Wo147a+A+CnrAqUXBPS9r6z 5koTji68K4721IH1O5uvLRilgmmDw9kaP1m0NhYQZnZmYwK0uhbog79xWD1nDpXCyVtA sknpjheDNGt3VdP8JVRZp9o54DByJ3V+7Ls97YU+Pn2tUMdFhqQQ48N3jnIM1I/ylT7L B27BQdydaq0Jck1+Ec1SXyYeUoW4Pj81V3w8DE3+OlhC7XMpiXduD7vw6EX2UQCUB71C TDNyJ3M3y5TCO7mSnbeNmVlLxz4iu9epWr4SWZEaH03EKcPC/IJ6jFIchfdNqIbKhrTk S1YQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w6si1098701pgp.496.2018.04.11.13.02.35; Wed, 11 Apr 2018 13:03:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756268AbeDKS4r (ORCPT + 99 others); Wed, 11 Apr 2018 14:56:47 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35904 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756252AbeDKS4n (ORCPT ); Wed, 11 Apr 2018 14:56:43 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 87C6BC06; Wed, 11 Apr 2018 18:56:42 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Stern , Sasha Levin Subject: [PATCH 4.9 067/310] USB: ene_usb6250: fix first command execution Date: Wed, 11 Apr 2018 20:33:26 +0200 Message-Id: <20180411183625.209846376@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183622.305902791@linuxfoundation.org> References: <20180411183622.305902791@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alan Stern [ Upstream commit 4b309f1c4972c8f09e03ac64fc63510dbf5591a4 ] In the ene_usb6250 sub-driver for usb-storage, the ene_transport() routine is supposed to initialize the driver before executing the current command, if the initialization has not already been performed. However, a bug in the routine causes it to skip the command after doing the initialization. Also, the routine does not return an appropriate error code if either the initialization or the command fails. As a result of the first bug, the first command (a SCSI INQUIRY) is not carried out. The results can be seen in the system log, in the form of a warning message and empty or garbage INQUIRY data: Apr 18 22:40:08 notebook2 kernel: scsi host6: scsi scan: INQUIRY result too short (5), using 36 Apr 18 22:40:08 notebook2 kernel: scsi 6:0:0:0: Direct-Access PQ: 0 ANSI: 0 This patch fixes both errors. Signed-off-by: Alan Stern Reported-and-tested-by: Andreas Hartmann Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/ene_ub6250.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/drivers/usb/storage/ene_ub6250.c +++ b/drivers/usb/storage/ene_ub6250.c @@ -2295,21 +2295,22 @@ static int ms_scsi_irp(struct us_data *u static int ene_transport(struct scsi_cmnd *srb, struct us_data *us) { - int result = 0; + int result = USB_STOR_XFER_GOOD; struct ene_ub6250_info *info = (struct ene_ub6250_info *)(us->extra); /*US_DEBUG(usb_stor_show_command(us, srb)); */ scsi_set_resid(srb, 0); - if (unlikely(!(info->SD_Status.Ready || info->MS_Status.Ready))) { + if (unlikely(!(info->SD_Status.Ready || info->MS_Status.Ready))) result = ene_init(us); - } else { + if (result == USB_STOR_XFER_GOOD) { + result = USB_STOR_TRANSPORT_ERROR; if (info->SD_Status.Ready) result = sd_scsi_irp(us, srb); if (info->MS_Status.Ready) result = ms_scsi_irp(us, srb); } - return 0; + return result; } static struct scsi_host_template ene_ub6250_host_template;