public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Hao Wu <hao.a.wu@intel.com>
To: edk2-devel@lists.01.org
Cc: Hao Wu <hao.a.wu@intel.com>, Ruiyu Ni <ruiyu.ni@intel.com>,
	Star Zeng <star.zeng@intel.com>, Eric Dong <eric.dong@intel.com>
Subject: [PATCH] MdeModulePkg/RamDiskDxe: Perform MediaId check first in BlkIo services
Date: Sat, 24 Feb 2018 08:48:03 +0800	[thread overview]
Message-ID: <20180224004803.12436-1-hao.a.wu@intel.com> (raw)

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 <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
 .../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.<BR>
+  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
   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;
   }
-- 
2.12.0.windows.1



             reply	other threads:[~2018-02-24  0:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-24  0:48 Hao Wu [this message]
2018-02-24  3:21 ` [PATCH] MdeModulePkg/RamDiskDxe: Perform MediaId check first in BlkIo services Ni, Ruiyu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180224004803.12436-1-hao.a.wu@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox