aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeif Lindholm <leif.lindholm@linaro.org>2017-04-12 15:23:47 +0100
committerLeif Lindholm <leif.lindholm@linaro.org>2017-04-13 15:24:01 +0100
commitbfce8b2fee783a471edcc07415f8033e578d43b1 (patch)
tree4423183ea60628e9880b960f3aaae3b759efdc5a
parent04a2f5be71bca8576612d4731d8bf3e1b5dbf464 (diff)
Drivers: MarvellYukonDxe driver binding fixes
Fix a case where MarvellYukonDriverStart attempted to free a buffer before it was allocated. Move another error case which wasn't freeing the same buffer before returning. Also correct the error message for that case, which was copied verbatim from the preceding if-statement. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org> Tested-by: Alan Ott <alan@softiron.co.uk> Tested-by: Daniil Egranov <daniil.egranov@arm.com> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
-rw-r--r--Drivers/Net/MarvellYukonDxe/DriverBinding.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/Drivers/Net/MarvellYukonDxe/DriverBinding.c b/Drivers/Net/MarvellYukonDxe/DriverBinding.c
index 947d738..0abc94e 100644
--- a/Drivers/Net/MarvellYukonDxe/DriverBinding.c
+++ b/Drivers/Net/MarvellYukonDxe/DriverBinding.c
@@ -127,7 +127,6 @@ MarvellYukonDriverStart (
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "Marvell Yukon: OpenProtocol: EFI_PCI_IO_PROTOCOL ERROR Status = %r\n", Status));
- gBS->FreePool (YukonDriver);
return Status;
}
@@ -146,6 +145,10 @@ MarvellYukonDriverStart (
}
for (Port = 0; Port < ScData->msk_num_port; Port++) {
+ if (ScData->msk_if[Port] == NULL) {
+ DEBUG ((DEBUG_ERROR, "Marvell Yukon: invalid buffer size\n"));
+ return EFI_BAD_BUFFER_SIZE;
+ }
Status = gBS->AllocatePool (EfiBootServicesData,
sizeof (YUKON_DRIVER),
@@ -155,11 +158,6 @@ MarvellYukonDriverStart (
return Status;
}
- if (ScData->msk_if[Port] == NULL) {
- DEBUG ((DEBUG_ERROR, "Marvell Yukon: AllocatePool() failed with Status = %r\n", EFI_BAD_BUFFER_SIZE));
- return EFI_BAD_BUFFER_SIZE;
- }
-
gBS->SetMem (YukonDriver, sizeof (YUKON_DRIVER), 0);
EfiInitializeLock (&YukonDriver->Lock, TPL_NOTIFY);