Received: by 10.192.165.156 with SMTP id m28csp1174865imm; Wed, 11 Apr 2018 13:55:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx48g5DD4lGo9fa7But8e/lB2WVbovelk2Rndvb7uL6E/BUhdPKlaZe7JOJPEjnQWZadjwTfA X-Received: by 10.99.172.86 with SMTP id z22mr4619168pgn.35.1523480148431; Wed, 11 Apr 2018 13:55:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523480148; cv=none; d=google.com; s=arc-20160816; b=rxA409/GoSwj8W/1d63p57riUx7oYsIcHosEsvqSCZ+0B8Ly3kH7RWVigFHyy8bO1Z WPHH1Qx7CGG/n6YnR7VsB7rr9QSYi/NQUFqYhjyCQdht29s3dMiHFeUWULwblLsY0pPd xPq0XMmIVzy8v2rkjcWz2fv8iT2fcgZP4ALBkDTHDXfOUvISdsEwsFrbKWoxhHlfEK3u LDu3mKv/09G8ULJiBfXU4gP04gDDfs/2wdTVsjVA3L1FnZf/HQsnbuXfJxnSw6s0opVC P9aLRoCS2j0s6YoJs2Ou4FZK/14MBU5ELFmwiIWKeBtc6++F2o1Ygx/QqXnvN/l85tL9 HKXA== 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=PL1jhu4Jylh6sNc7avSJlO9H3zNvnCzTI8TIbLIAzIs=; b=Gk66Rl9xt3rAjB8Icnw8FT3qdrK6PA4abHqXJM8NYuJ9vmXdbpofOO+p/Mt5LspVTa zAlMTT6hMJ2lHbnoZEX9IhMWalfjS5fHdK+cyd1kQiCi/61hE8Z/Ll2R89bAVkJu2oAT eUMZkF0s0UmRf42doB1Efdfk9f8s9NHg08RJ8EaNU7F7ZFlI8negGbUz0K6U6jRxIyql Fso1fjLd3+BHiy4TK1RXZ9GxaEzcoMau+9C8zkNT00Rup/wkiYgUTiCSP7UpzO6EWwCS 3IEA05h2sfsAdKafke3MJHp5oZ7PwY/3vKAiUKl5+xebBSbyN2e0fYEwBpb8CDxtKb9G hFxA== 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 9si1193717pge.750.2018.04.11.13.55.11; Wed, 11 Apr 2018 13:55:48 -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 S1755519AbeDKSpZ (ORCPT + 99 others); Wed, 11 Apr 2018 14:45:25 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58560 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755500AbeDKSpV (ORCPT ); Wed, 11 Apr 2018 14:45:21 -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 4AD712F; Wed, 11 Apr 2018 18:45:20 +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.4 044/190] USB: ene_usb6250: fix first command execution Date: Wed, 11 Apr 2018 20:34:50 +0200 Message-Id: <20180411183552.695455701@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183550.114495991@linuxfoundation.org> References: <20180411183550.114495991@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.4-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 @@ -2306,21 +2306,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;