diff options
author | Dov Murik <dovmurik@linux.ibm.com> | 2021-06-28 10:51:06 +0000 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2021-06-29 12:33:17 +0000 |
commit | 5a2e030f733752a8029bccfa7d28679e103540e0 (patch) | |
tree | d214669dd52d2cfc53cbf7bb7d51b63b191e0dbc /OvmfPkg | |
parent | d1fc3d7ef3cb77c63409f5ad873eb37302fa3481 (diff) | |
download | edk2-5a2e030f733752a8029bccfa7d28679e103540e0.zip edk2-5a2e030f733752a8029bccfa7d28679e103540e0.tar.gz edk2-5a2e030f733752a8029bccfa7d28679e103540e0.tar.bz2 |
OvmfPkg/GenericQemuLoadImageLib: plug cmdline blob leak on success
When QemuLoadKernelImage() ends successfully, the command-line blob is
not freed, even though it is not used elsewhere (its content is already
copied to KernelLoadedImage->LoadOptions). The memory leak bug was
introduced in commit ddd2be6b0026 ("OvmfPkg: provide a generic
implementation of QemuLoadImageLib", 2020-03-05).
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Tobin Feldman-Fitzthum <tobin@linux.ibm.com>
Reported-by: Laszlo Ersek <lersek@redhat.com>
Fixes: ddd2be6b0026abcd0f819b3915fc80c3de81dd62
Signed-off-by: Dov Murik <dovmurik@linux.ibm.com>
Message-Id: <20210628105110.379951-2-dovmurik@linux.ibm.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Diffstat (limited to 'OvmfPkg')
-rw-r--r-- | OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c b/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c index 114db7e..8a29976 100644 --- a/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c +++ b/OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.c @@ -193,14 +193,16 @@ QemuLoadKernelImage ( }
*ImageHandle = KernelImageHandle;
- return EFI_SUCCESS;
+ Status = EFI_SUCCESS;
FreeCommandLine:
if (CommandLineSize > 0) {
FreePool (CommandLine);
}
UnloadImage:
- gBS->UnloadImage (KernelImageHandle);
+ if (EFI_ERROR (Status)) {
+ gBS->UnloadImage (KernelImageHandle);
+ }
return Status;
}
|