From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.107.92.56]) by mx.groups.io with SMTP id smtpd.web12.303.1667015979110171804 for ; Fri, 28 Oct 2022 20:59:39 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=HUFRIc99; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.92.56, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eziJB7g0uXlBLQzMeP4aBdsTFkX+W+b/KGxjgY5N5rwP6ICSD0/7d1wi5rWvpWXOtXZF5+lD9IlOsyUEo2m/JZwWt9mxsyWQMMDejwd9MgT8TGLL1BCoQbSxnuwy8M6J3S9FYV5FqSqpOpEbW+j5FYIdx/qy+rWoj4j6Q1OIXC5m91D6RYCOlQHA6IhzOpmazOgqPJdBpVNaH5oP5Rb4GxRuG9yTS4pAlJUm+Ewa6q0hbxkypcTVU3RDfeku8mkAPWnZpu9PaXZT6niRisuneIAt5ne47npvU8bumKRevWI0FlMIA1wVVJMoSHinMAOa1qDDr8DluxzFGvFlwOhCVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=43X8B4II9aCDxv4eh7sB+7rjNlQ7Zm3TD9eOXpKGJxI=; b=nDLexuQQPThwkgtSoCdiaxWhvRmaEE8tesWn5yDTkRiYWXOTK2Ujn1DkRoTKI+qDRgEsxdOi/7B1BOD+9G/XxiMVBwzMQHxzpFwORoE7Gi3dzbSwSL/admQzPIkuiHzsyo0kpraD1T91bUQPpupsGkW4Ey2dSVd1Rj5UO7yT/qUHjH/j6zvHoswBokbzxJpXnW8nuXvv8JrCa5/s9x0jUDEYy0Kd6vFgtmdlNA34OCD1wJkFLvIVs8qnewlTYZy4nGXMRrMdh49+0m98Un9ylo7/rIdEXAc//jeFCdg+TV6bbwMULpuf+6PT5ocRd1IQosAFT3HVJM3sFT7u/byn2w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=43X8B4II9aCDxv4eh7sB+7rjNlQ7Zm3TD9eOXpKGJxI=; b=HUFRIc99qyVe6DRdUjlV46hveJWdt/cjJ9Z6FHeACCfWEfXGrCh3CROyh0p5LwgHbNKa0NPA91aheI743nnPK5QO14tUIewdH86T50x7cI2oDg+WeECy8SSnKax1ONzAGdTFihVFqNaE3Wqpj9Pn/m88F0bjIPHfCPqvSiNGUvk= Received: from BN0PR02CA0057.namprd02.prod.outlook.com (2603:10b6:408:e5::32) by IA1PR12MB6411.namprd12.prod.outlook.com (2603:10b6:208:388::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.15; Sat, 29 Oct 2022 03:59:35 +0000 Received: from BN8NAM11FT090.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e5:cafe::2f) by BN0PR02CA0057.outlook.office365.com (2603:10b6:408:e5::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.15 via Frontend Transport; Sat, 29 Oct 2022 03:59:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT090.mail.protection.outlook.com (10.13.177.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5769.14 via Frontend Transport; Sat, 29 Oct 2022 03:59:35 +0000 Received: from TPE-L1-ABNCHANG.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 28 Oct 2022 22:59:33 -0500 From: "Chang, Abner" To: CC: Nickle Wang , Igor Kulchytskyy Subject: [PATCH] RedfishPkg/RedfishDiscoverDxe: Fix memory free issue Date: Sat, 29 Oct 2022 11:59:11 +0800 Message-ID: <20221029035911.651-1-abner.chang@amd.com> X-Mailer: git-send-email 2.37.1.windows.1 MIME-Version: 1.0 Return-Path: Abner.Chang@amd.com X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT090:EE_|IA1PR12MB6411:EE_ X-MS-Office365-Filtering-Correlation-Id: 829e6a97-7512-4f0d-0285-08dab961fe65 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YMkdt9YAS9K0BCJ9DRFffMK2uebRZURee+s4gcXVM9+A51P+JXrUHqU2Ayner1D3Uxq+tZZd2OerphCGQEQNLDdPXsGv8ewir/3Pv5wwBMuYkYSGz36Dr2fYrI4Y866NAChZCB7QxouKbgisg4yOGyZZNmfIRzZMSXb3Y0quvw+xW6MTgRJU+qqV2zc/HaF/X9XtAqK/oI/gKKvcziZOyO1CmKVOrVBF01Pg3niGnhhjtrVj+tsNPWGGH7ZnnIfFA/Baqi/tvqwXOcgKR9r2E+sE1+Of5LXly6XUzehqFIeNYBUFPDqfIBLk+5zX39mDLWGgapvxbjfLxSCEFbrYGUk8ujROnc9sEZs4IaPQYby8FYutoAqcIu9eCHjWVPocf/WIlQ+dfFBhsFoQRB28rBX3pz6CrzK5FUDo6HCIlehS344S5/xp7VmOcgzgk6RxfVz+YLIiNAva3fetwVH8YzUo6N/6+rluyucIU/bvM7/NCaseyqJ9nXI7nK04FNR7ZC0tW6wGZ3nOImUhQVCFB+nkz64+TnNkIi+cPm9X8XysmRK4N2ow3ExgImrrt972n1vdGmPTFMGtbMZT/+RIXyDfwlImY0hqadlw3Xs/YCKHvLaNLZ39fRb37w8qYKKhKNoHwla8QSe1i72EiOVPBvrpUyUVNgQ1cyaSSPWQZpZ01SmPG8b2VdryCtVEg4WgnIFCxJAPvpFwFhKjS7ifVzqcTVyP5lb4IlEuSv6t0A1jpGTVQv1P3qKFfjSJ2q8b1XCyUKksdrJZPy5YC8Au5m6qtrECwA6rq1sdV3hBlK9Q+QiedB/OCYcJq0e2OuCw X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(136003)(376002)(346002)(39860400002)(396003)(451199015)(46966006)(36840700001)(40470700004)(83380400001)(86362001)(478600001)(356005)(82740400003)(81166007)(316002)(36860700001)(6916009)(40480700001)(426003)(82310400005)(8676002)(8936002)(4326008)(7696005)(2616005)(47076005)(70586007)(70206006)(2906002)(16526019)(336012)(54906003)(41300700001)(186003)(1076003)(6666004)(40460700003)(2876002)(5660300002)(36756003)(26005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Oct 2022 03:59:35.7032 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 829e6a97-7512-4f0d-0285-08dab961fe65 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT090.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6411 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain From: Abner Chang Check the memory block pointer before freeing it. Cc: Nickle Wang Cc: Igor Kulchytskyy Signed-off-by: Abner Chang --- .../RedfishDiscoverDxe/RedfishDiscoverDxe.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/RedfishPk= g/RedfishDiscoverDxe/RedfishDiscoverDxe.c index 1293ddd633c..1616b5134bc 100644 --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c @@ -261,6 +261,7 @@ Tcp6GetSubnetInfo ( =20 Tcp6 =3D (EFI_TCP6_PROTOCOL *)Instance->NetworkInterfaceProtocolInfo.Net= workProtocolInterface; =20 + ZeroMem ((VOID *)&IpModedata, sizeof (EFI_IP6_MODE_DATA)); Status =3D Tcp6->GetModeData (Tcp6, NULL, NULL, &IpModedata, NULL, NULL)= ; if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: Can't get IP mode data information\n", __FUN= CTION__)); @@ -282,12 +283,15 @@ Tcp6GetSubnetInfo ( } =20 Instance->SubnetAddrInfoIPv6Number =3D IpModedata.AddressCount; - CopyMem ( - (VOID *)Instance->SubnetAddrInfoIPv6, - (VOID *)&IpModedata.AddressList, - IpModedata.AddressCount * sizeof (EFI_IP6_ADDRESS_INFO) - ); - FreePool (IpModedata.AddressList); + if (IpModedata.AddressCount !=3D 0 && IpModedata.AddressList !=3D NULL) = { + CopyMem ( + (VOID *)Instance->SubnetAddrInfoIPv6, + (VOID *)&IpModedata.AddressList, + IpModedata.AddressCount * sizeof (EFI_IP6_ADDRESS_INFO) + ); + FreePool(IpModedata.AddressList); + } + return EFI_SUCCESS; } =20 --=20 2.37.1.windows.1