ShellPkg/Shell: Do not set end device path if already end

Update Shell Protocol EfiShellGetMapFromDevicePath() to not
set the end if the device path if it is already an end of
entire device path.  This removes a write operation that can
cause failures if the Device Path Protocol is mapped to
read-only memory.  In general Device Path Protocols should not
be modified unless the API explicitly states that the device
path is modified.

Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
This commit is contained in:
Michael D Kinney 2022-12-09 07:53:21 -08:00 committed by mergify[bot]
parent 1fd8d08970
commit 592bf33a29
1 changed files with 7 additions and 1 deletions

View File

@ -294,8 +294,14 @@ EfiShellGetMapFromDevicePath (
*DevicePath = NextDevicePathNode (*DevicePath); *DevicePath = NextDevicePathNode (*DevicePath);
} }
//
// Do not call SetDevicePathEndNode() if the device path node is already the
// end of an entire device path.
//
if (!IsDevicePathEnd (*DevicePath)) {
SetDevicePathEndNode (*DevicePath); SetDevicePathEndNode (*DevicePath);
} }
}
/* /*
///@todo finish code for inexact matches. ///@todo finish code for inexact matches.