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 8D9B920349D98 for ; Mon, 13 Nov 2017 01:40:47 -0800 (PST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Nov 2017 01:44:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,388,1505804400"; d="scan'208";a="1647476" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga003.jf.intel.com with ESMTP; 13 Nov 2017 01:44:52 -0800 Received: from fmsmsx123.amr.corp.intel.com (10.18.125.38) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 13 Nov 2017 01:44:51 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx123.amr.corp.intel.com (10.18.125.38) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 13 Nov 2017 01:44:51 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.175]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.213]) with mapi id 14.03.0319.002; Mon, 13 Nov 2017 17:44:49 +0800 From: "Zeng, Star" To: "Kinney, Michael D" , "edk2-devel@lists.01.org" CC: "Dong, Eric" , "Zeng, Star" Thread-Topic: [Patch] MdeModulePkg/UsbMassStorageDxe: Verify Get Max LUN value Thread-Index: AQHTWN+eXF7PFpDFEkyCy6xj11CT3KMSE+2Q Date: Mon, 13 Nov 2017 09:44:48 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B9B495E@shsmsx102.ccr.corp.intel.com> References: <20171108221906.6544-1-michael.d.kinney@intel.com> In-Reply-To: <20171108221906.6544-1-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] MdeModulePkg/UsbMassStorageDxe: Verify Get Max LUN 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: Mon, 13 Nov 2017 09:40:47 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Star Zeng How about also adding the compatibility info(now in commit log) to the code= comments? For example, + // + // If MaxLun is larger than the maximum LUN value (0x0f) supported by = the + // USB Mass Storage Class Bulk-Only Transport Spec, then set MaxLun to= 0 + // which means no LUN is associated with the device. + // It improves compatibility with USB FLASH drives that have a single = LUN, + // but return invalid maximum LUN values. + // Thanks, Star -----Original Message----- From: Kinney, Michael D=20 Sent: Thursday, November 9, 2017 6:19 AM To: edk2-devel@lists.01.org Cc: Zeng, Star ; Dong, Eric Subject: [Patch] MdeModulePkg/UsbMassStorageDxe: Verify Get Max LUN value 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 have a single= LUN, but return invalid maximum LUN values. 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 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.c b/MdeModul= ePkg/Bus/Usb/UsbMassStorageDxe/UsbMassBot.c index 4bb7222b89..c7436cf036 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,14 @@ UsbBotGetMaxLun ( 1, &Result ); + if (!EFI_ERROR (Status) && *MaxLun > USB_BOT_MAX_LUN) { + // + // If MaxLun is larger than the maximum LUN value (0x0f) supported by = the + // USB Mass Storage Class Bulk-Only Transport Spec, then set MaxLun to= 0 + // which means no LUN is associated with the device. + // + *MaxLun =3D 0; + } =20 return Status; } -- 2.14.2.windows.3