\r
/**\r
Determine whether a given device path is valid.\r
- If DevicePath is NULL, then ASSERT().\r
\r
@param DevicePath A pointer to a device path data structure.\r
@param MaxSize The maximum size of the device path data structure.\r
\r
@retval TRUE DevicePath is valid.\r
+ @retval FALSE DevicePath is NULL.\r
+ @retval FALSE Maxsize is less than sizeof(EFI_DEVICE_PATH_PROTOCOL).\r
@retval FALSE The length of any node node in the DevicePath is less\r
than sizeof (EFI_DEVICE_PATH_PROTOCOL).\r
@retval FALSE If MaxSize is not zero, the size of the DevicePath\r
UINTN Size;\r
UINTN NodeLength;\r
\r
- ASSERT (DevicePath != NULL);\r
-\r
- if (MaxSize == 0) {\r
- MaxSize = MAX_UINT32;\r
- }\r
-\r
//\r
- // Validate the input size big enough to touch the first node.\r
+ // Validate the input whether exists and its size big enough to touch the first node\r
//\r
- if (MaxSize < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {\r
+ if (DevicePath == NULL || (MaxSize > 0 && MaxSize < END_DEVICE_PATH_LENGTH)) {\r
return FALSE;\r
}\r
\r
+ if (MaxSize == 0) {\r
+ MaxSize = MAX_UINT32;\r
+ }\r
+\r
for (Count = 0, Size = 0; !IsDevicePathEnd (DevicePath); DevicePath = NextDevicePathNode (DevicePath)) {\r
NodeLength = DevicePathNodeLength (DevicePath);\r
if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {\r