MdeModulePkg/RamDiskDxe: fix memory leak on error path.

This patch fixes a leak of memory allocated for the RAM disk in cases
when an error occurred while reading contents of a file from disk
or RamDiskRegister() returned some error condition.

Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
This commit is contained in:
Mike Maslenkin 2024-04-27 12:14:36 +03:00 committed by mergify[bot]
parent b158dad150
commit 1cc0fae8d9
1 changed files with 7 additions and 2 deletions

View File

@ -404,7 +404,8 @@ HiiCreateRamDisk (
);
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
return EFI_DEVICE_ERROR;
Status = EFI_DEVICE_ERROR;
goto ErrorExit;
}
}
@ -431,7 +432,7 @@ HiiCreateRamDisk (
);
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
return Status;
goto ErrorExit;
}
//
@ -442,6 +443,10 @@ HiiCreateRamDisk (
PrivateData->CreateMethod = RamDiskCreateHii;
return EFI_SUCCESS;
ErrorExit:
gBS->FreePool (StartingAddr);
return Status;
}
/**