OcDebugLogLib: Fix null pointer dereference
@@ -355,13 +355,6 @@ OcLogAddEntry (
return Status;
}
-/**
- Retrieve pointer to the log buffer
-
- @param[in] This This protocol.
- @param[in] OcLogBuffer Address to store the buffer pointer.
-
-**/
EFI_STATUS
EFIAPI
OcLogGetLog (
@@ -385,15 +378,6 @@ OcLogGetLog (
return Status;
}
-/**
- Save the current log
-
- @param[in] This This protocol.
- @param[in] NonVolatile Variable.
- @param[in] FilePath Filepath to save the log, optional.
-
- @retval EFI_SUCCESS The log was saved successfully.
-**/
EFI_STATUS
EFIAPI
OcLogSaveLog (
@@ -405,13 +389,6 @@ OcLogSaveLog (
return EFI_NOT_FOUND;
}
-/**
- Reset the internal timers
-
- @param[in] This This protocol.
-
- @retval EFI_SUCCESS The timers were reset successfully.
-**/
EFI_STATUS
EFIAPI
OcLogResetTimers (
@@ -421,18 +398,6 @@ OcLogResetTimers (
return EFI_SUCCESS;
}
-/**
- Install or update the OcLog protocol with specified options.
-
- @param[in] Options Logging options.
- @param[in] DisplayDelay Delay in microseconds after each displayed log entry.
- @param[in] DisplayLevel Console visible error level.
- @param[in] HaltLevel Error level causing CPU halt.
- @param[in] LogPrefixPath Log path (without timestamp).
- @param[in] LogFileSystem Log filesystem, optional.
-
- @retval EFI_SUCCESS The entry point is executed successfully.
-**/
EFI_STATUS
OcConfigureLogProtocol (
IN OC_LOG_OPTIONS Options,
@@ -451,11 +416,12 @@ OcConfigureLogProtocol (
EFI_FILE_PROTOCOL *LogRoot;
CHAR16 *LogPath;
+ if ((Options & (OC_LOG_FILE | OC_LOG_ENABLE)) == (OC_LOG_FILE | OC_LOG_ENABLE)) {
LogRoot = NULL;
LogPath = GetLogPath (LogPrefixPath);
- if ((Options & (OC_LOG_FILE | OC_LOG_ENABLE)) == (OC_LOG_FILE | OC_LOG_ENABLE)) {
- if (LogFileSystem != NULL && LogPath != NULL) {
+ if (LogPath != NULL) {
+ if (LogFileSystem != NULL) {
Status = LogFileSystem->OpenVolume (LogFileSystem, &LogRoot);
if (EFI_ERROR (Status)) {
LogRoot = NULL;
@@ -469,6 +435,15 @@ OcConfigureLogProtocol (
LogRoot = NULL;
}
}
+
+ if (LogRoot == NULL) {
+ FreePool (LogPath);
+ LogPath = NULL;
+ }
+ }
+ } else {
+ LogRoot = NULL;
+ LogPath = NULL;
}
//
@@ -550,12 +525,9 @@ OcConfigureLogProtocol (
);
} else {
LogRoot->Close (LogRoot);
- }
- }
-
- if (EFI_ERROR (Status) && LogPath != NULL) {
FreePool (LogPath);
}
+ }
return Status;
}
