\r
TempNewDevicePath = CachedDevicePath;\r
CachedDevicePath = AppendDevicePathInstance (BlockIoDevicePath, CachedDevicePath);\r
- FreePool(TempNewDevicePath);\r
+ if (TempNewDevicePath != NULL) {\r
+ FreePool(TempNewDevicePath);\r
+ }\r
} else {\r
TempNewDevicePath = CachedDevicePath;\r
CachedDevicePath = AppendDevicePathInstance (BlockIoDevicePath, CachedDevicePath);\r
}\r
}\r
\r
- FreePool (CachedDevicePath);\r
+ if (CachedDevicePath != NULL) {\r
+ FreePool (CachedDevicePath);\r
+ }\r
if (BlockIoBuffer != NULL) {\r
FreePool (BlockIoBuffer);\r
}\r