diff options
author | Abner Chang <abner.chang@amd.com> | 2022-10-28 18:16:55 +0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2022-11-01 01:17:57 +0000 |
commit | df7ce74e6c75e19a528d5b4921e5b3d0260e45fe (patch) | |
tree | 88707ae98746b62a72a89e7845eda6b21e9f5d9b /RedfishPkg/RedfishDiscoverDxe | |
parent | 66772bc8523ce7898eb470efc7aef65c2062b2aa (diff) | |
download | edk2-df7ce74e6c75e19a528d5b4921e5b3d0260e45fe.tar.gz edk2-df7ce74e6c75e19a528d5b4921e5b3d0260e45fe.tar.bz2 edk2-df7ce74e6c75e19a528d5b4921e5b3d0260e45fe.zip |
RedfishPkg/RedfishDiscoverDxe: Fix memory free issue
Check the memory block pointer before freeing it.
Cc: Nickle Wang <nicklew@nvidia.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Signed-off-by: Abner Chang <abner.chang@amd.com>
Reviewed-by: Nickle Wang <nicklew@nvidia.com>
Diffstat (limited to 'RedfishPkg/RedfishDiscoverDxe')
-rw-r--r-- | RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c index 1293ddd633..042d6d5fd5 100644 --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c @@ -261,6 +261,7 @@ Tcp6GetSubnetInfo ( Tcp6 = (EFI_TCP6_PROTOCOL *)Instance->NetworkInterfaceProtocolInfo.NetworkProtocolInterface;
+ ZeroMem ((VOID *)&IpModedata, sizeof (EFI_IP6_MODE_DATA));
Status = Tcp6->GetModeData (Tcp6, NULL, NULL, &IpModedata, NULL, NULL);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: Can't get IP mode data information\n", __FUNCTION__));
@@ -282,12 +283,15 @@ Tcp6GetSubnetInfo ( }
Instance->SubnetAddrInfoIPv6Number = IpModedata.AddressCount;
- CopyMem (
- (VOID *)Instance->SubnetAddrInfoIPv6,
- (VOID *)&IpModedata.AddressList,
- IpModedata.AddressCount * sizeof (EFI_IP6_ADDRESS_INFO)
- );
- FreePool (IpModedata.AddressList);
+ if ((IpModedata.AddressCount != 0) && (IpModedata.AddressList != NULL)) {
+ CopyMem (
+ (VOID *)Instance->SubnetAddrInfoIPv6,
+ (VOID *)&IpModedata.AddressList,
+ IpModedata.AddressCount * sizeof (EFI_IP6_ADDRESS_INFO)
+ );
+ FreePool (IpModedata.AddressList);
+ }
+
return EFI_SUCCESS;
}
|