Skip to content

Commit

Permalink
MdeModulePkg/RamDiskDxe: fix memory leak on error path.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ghbaccount authored and mergify[bot] committed Aug 26, 2024
1 parent b158dad commit 1cc0fae
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,8 @@ HiiCreateRamDisk (
);
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);

return EFI_DEVICE_ERROR;
Status = EFI_DEVICE_ERROR;
goto ErrorExit;
}
}

Expand All @@ -431,7 +432,7 @@ HiiCreateRamDisk (
);
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);

return Status;
goto ErrorExit;
}

//
Expand All @@ -442,6 +443,10 @@ HiiCreateRamDisk (
PrivateData->CreateMethod = RamDiskCreateHii;

return EFI_SUCCESS;

ErrorExit:
gBS->FreePool (StartingAddr);
return Status;
}

/**
Expand Down

0 comments on commit 1cc0fae

Please sign in to comment.