From nobody Mon Apr 29 15:18:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1519433290760314.1687856627177; Fri, 23 Feb 2018 16:48:10 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id C8A9D222A334B; Fri, 23 Feb 2018 16:42:06 -0800 (PST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 47CA1222630D6 for ; Fri, 23 Feb 2018 16:42:04 -0800 (PST) Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Feb 2018 16:48:06 -0800 Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.10]) by fmsmga008.fm.intel.com with ESMTP; 23 Feb 2018 16:48:05 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,385,1515484800"; d="scan'208";a="19994444" From: Hao Wu To: edk2-devel@lists.01.org Date: Sat, 24 Feb 2018 08:48:03 +0800 Message-Id: <20180224004803.12436-1-hao.a.wu@intel.com> X-Mailer: git-send-email 2.12.0.windows.1 Subject: [edk2] [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: , Cc: Hao Wu , Ruiyu Ni , Eric Dong , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Ruiyu Ni --- .../Universal/Disk/RamDiskDxe/RamDiskBlockIo.c | 30 +++++++++++-------= ---- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskBlockIo.c b/MdeM= odulePkg/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. =20 - 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 BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -137,6 +137,12 @@ RamDiskBlkIoReadBlocks ( RAM_DISK_PRIVATE_DATA *PrivateData; UINTN NumberOfBlocks; =20 + PrivateData =3D RAM_DISK_PRIVATE_FROM_BLKIO (This); + + if (MediaId !=3D PrivateData->Media.MediaId) { + return EFI_MEDIA_CHANGED; + } + if (Buffer =3D=3D NULL) { return EFI_INVALID_PARAMETER; } @@ -145,12 +151,6 @@ RamDiskBlkIoReadBlocks ( return EFI_SUCCESS; } =20 - PrivateData =3D RAM_DISK_PRIVATE_FROM_BLKIO (This); - - if (MediaId !=3D PrivateData->Media.MediaId) { - return EFI_MEDIA_CHANGED; - } - if ((BufferSize % PrivateData->Media.BlockSize) !=3D 0) { return EFI_BAD_BUFFER_SIZE; } @@ -212,14 +212,6 @@ RamDiskBlkIoWriteBlocks ( RAM_DISK_PRIVATE_DATA *PrivateData; UINTN NumberOfBlocks; =20 - if (Buffer =3D=3D NULL) { - return EFI_INVALID_PARAMETER; - } - - if (BufferSize =3D=3D 0) { - return EFI_SUCCESS; - } - PrivateData =3D RAM_DISK_PRIVATE_FROM_BLKIO (This); =20 if (MediaId !=3D PrivateData->Media.MediaId) { @@ -230,6 +222,14 @@ RamDiskBlkIoWriteBlocks ( return EFI_WRITE_PROTECTED; } =20 + if (Buffer =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + if (BufferSize =3D=3D 0) { + return EFI_SUCCESS; + } + if ((BufferSize % PrivateData->Media.BlockSize) !=3D 0) { return EFI_BAD_BUFFER_SIZE; } --=20 2.12.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel