From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 23718220D4C07 for ; Tue, 14 Nov 2017 18:33:56 -0800 (PST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Nov 2017 18:38:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,397,1505804400"; d="scan'208";a="149591387" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga004.jf.intel.com with ESMTP; 14 Nov 2017 18:38:03 -0800 Received: from fmsmsx155.amr.corp.intel.com (10.18.116.71) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 14 Nov 2017 18:38:01 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX155.amr.corp.intel.com (10.18.116.71) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 14 Nov 2017 18:38:00 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.175]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.218]) with mapi id 14.03.0319.002; Wed, 15 Nov 2017 10:37:58 +0800 From: "Zeng, Star" To: "Kinney, Michael D" , "edk2-devel@lists.01.org" CC: "Dong, Eric" , "Zeng, Star" Thread-Topic: [Patch V2 2/2] MdeModulePkg/UsbMassStorageDxe: Check Get Max LUN status/value Thread-Index: AQHTXa2HEkAGX/g9GkeUjt/J0yTfo6MUubeQ Date: Wed, 15 Nov 2017 02:37:57 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B9B54F2@shsmsx102.ccr.corp.intel.com> References: <20171115010236.1344-1-michael.d.kinney@intel.com> <20171115010236.1344-3-michael.d.kinney@intel.com> In-Reply-To: <20171115010236.1344-3-michael.d.kinney@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch V2 2/2] MdeModulePkg/UsbMassStorageDxe: Check Get Max LUN status/value X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Nov 2017 02:33:56 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Mike, With a minor typo "that o not" fixed to "that do not" in the commit log, Re= viewed-by: Star Zeng Thanks, Star -----Original Message----- From: Kinney, Michael D=20 Sent: Wednesday, November 15, 2017 9:03 AM To: edk2-devel@lists.01.org Cc: Zeng, Star ; Dong, Eric Subject: [Patch V2 2/2] MdeModulePkg/UsbMassStorageDxe: Check Get Max LUN s= tatus/value https://bugzilla.tianocore.org/show_bug.cgi?id=3D767 If a USB Mass Storage device does not support the Get Max LUN command, then= the USB I/O Protocol ControlTransfer() service may return an error. If an= error is returned for this command, then assume that the device does not s= upport multiple LUNs and return a maximum LUN value of 0. The USB Mass Storage Class Specification states that a maximum LUN value la= rger than 0x0F is invalid. Add a check to make sure this maximum LUN value= is in this valid range, and if it is not, then assume that the device does= not support multiple LUNs and return a maximum LUN value of 0. This change improves compatibility with USB FLASH drives that o not support= the Get Max LUN command or return an invalid maximum LUN value. Cc: Star Zeng Cc: Eric Dong Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney --- MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.c b/MdeModul= ePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.c index 4bb7222b89..6afe2ae235 100644 --- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.c +++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.c @@ -2,7 +2,7 @@ Implementation of the USB mass storage Bulk-Only Transport protocol, according to USB Mass Storage Class Bulk-Only Transport, Revision 1.0. =20 -Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made availab= le under the terms and conditions of the BSD License which accompanies thi= s distribution. The full text of the license may be found at @@ -576,6 +57= 6,18 @@ UsbBotGetMaxLun ( 1, &Result ); + if (EFI_ERROR (Status) || *MaxLun > USB_BOT_MAX_LUN) { + // + // If the Get LUN request returns an error or the MaxLun is larger tha= n + // the maximum LUN value (0x0f) supported by the USB Mass Storage Clas= s + // Bulk-Only Transport Spec, then set MaxLun to 0. + // + // This improves compatibility with USB FLASH drives that have a singl= e LUN + // and either do not return a max LUN value or return an invalid maxim= um LUN + // value. + // + *MaxLun =3D 0; + } =20 return Status; } -- 2.14.2.windows.3