From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.126; helo=mga18.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (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 C6F67222630DB for ; Fri, 23 Feb 2018 19:15:02 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Feb 2018 19:21:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,386,1515484800"; d="scan'208";a="33216199" Received: from ray-dev.ccr.corp.intel.com (HELO [10.239.9.13]) ([10.239.9.13]) by fmsmga001.fm.intel.com with ESMTP; 23 Feb 2018 19:21:04 -0800 To: edk2-devel@lists.01.org References: <20180224004803.12436-1-hao.a.wu@intel.com> From: "Ni, Ruiyu" Message-ID: <5df097ed-a92e-72b9-f654-62138b98d608@Intel.com> Date: Sat, 24 Feb 2018 11:21:03 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180224004803.12436-1-hao.a.wu@intel.com> Subject: Re: [PATCH] MdeModulePkg/RamDiskDxe: Perform MediaId check first in BlkIo services X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Feb 2018 03:15:03 -0000 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit On 2/24/2018 8:48 AM, Hao Wu wrote: > The commit places the check for MediaId at the beginning of Block IO > services: > RamDiskBlkIoReadBlocks and > RamDiskBlkIoWriteBlocks > > This aligns with the Block IO protocol implementations for other > devices. > > Cc: Ruiyu Ni > Cc: Star Zeng > Cc: Eric Dong > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Hao Wu > --- > .../Universal/Disk/RamDiskDxe/RamDiskBlockIo.c | 30 +++++++++++----------- > 1 file changed, 15 insertions(+), 15 deletions(-) > > diff --git a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskBlockIo.c b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskBlockIo.c > index f36e1c8ff2..4f74b5ef15 100644 > --- a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskBlockIo.c > +++ b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskBlockIo.c > @@ -1,7 +1,7 @@ > /** @file > Produce EFI_BLOCK_IO_PROTOCOL on a RAM disk device. > > - Copyright (c) 2016, Intel Corporation. All rights reserved.
> + Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BSD License > which accompanies this distribution. The full text of the license may be found at > @@ -137,6 +137,12 @@ RamDiskBlkIoReadBlocks ( > RAM_DISK_PRIVATE_DATA *PrivateData; > UINTN NumberOfBlocks; > > + PrivateData = RAM_DISK_PRIVATE_FROM_BLKIO (This); > + > + if (MediaId != PrivateData->Media.MediaId) { > + return EFI_MEDIA_CHANGED; > + } > + > if (Buffer == NULL) { > return EFI_INVALID_PARAMETER; > } > @@ -145,12 +151,6 @@ RamDiskBlkIoReadBlocks ( > return EFI_SUCCESS; > } > > - PrivateData = RAM_DISK_PRIVATE_FROM_BLKIO (This); > - > - if (MediaId != PrivateData->Media.MediaId) { > - return EFI_MEDIA_CHANGED; > - } > - > if ((BufferSize % PrivateData->Media.BlockSize) != 0) { > return EFI_BAD_BUFFER_SIZE; > } > @@ -212,14 +212,6 @@ RamDiskBlkIoWriteBlocks ( > RAM_DISK_PRIVATE_DATA *PrivateData; > UINTN NumberOfBlocks; > > - if (Buffer == NULL) { > - return EFI_INVALID_PARAMETER; > - } > - > - if (BufferSize == 0) { > - return EFI_SUCCESS; > - } > - > PrivateData = RAM_DISK_PRIVATE_FROM_BLKIO (This); > > if (MediaId != PrivateData->Media.MediaId) { > @@ -230,6 +222,14 @@ RamDiskBlkIoWriteBlocks ( > return EFI_WRITE_PROTECTED; > } > > + if (Buffer == NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + if (BufferSize == 0) { > + return EFI_SUCCESS; > + } > + > if ((BufferSize % PrivateData->Media.BlockSize) != 0) { > return EFI_BAD_BUFFER_SIZE; > } > Reviewed-by: Ruiyu Ni -- Thanks, Ray