From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 820A221A04830 for ; Tue, 2 May 2017 08:17:36 -0700 (PDT) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP; 02 May 2017 08:17:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,405,1491289200"; d="scan'208";a="82881360" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga004.jf.intel.com with ESMTP; 02 May 2017 08:17:36 -0700 Received: from fmsmsx152.amr.corp.intel.com (10.18.125.5) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 2 May 2017 08:17:36 -0700 Received: from fmsmsx103.amr.corp.intel.com ([169.254.2.246]) by FMSMSX152.amr.corp.intel.com ([169.254.6.30]) with mapi id 14.03.0319.002; Tue, 2 May 2017 08:17:35 -0700 From: "Carsey, Jaben" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" CC: "Chen, Chen A" Thread-Topic: [PATCH] ShellPkg/UefiHandleParsingLib: Fix memory leak Thread-Index: AQHSwydM2D/ZRHeg9EuUlSK72TF0T6HhKB/Q Date: Tue, 2 May 2017 15:17:35 +0000 Message-ID: References: <20170502093417.112428-1-ruiyu.ni@intel.com> In-Reply-To: <20170502093417.112428-1-ruiyu.ni@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYzIzZTQ5ZjMtOGU2MS00MTAyLTg0OWItNjQ4MDgxNzk4YzRiIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IlRrM1F4eFVKeVNrNUNTdkJUb2dWYmpmMGtzTFkyXC9sMXhiSmQ0bW5OS3RjPSJ9 x-ctpclassification: CTP_IC x-originating-ip: [10.1.200.107] MIME-Version: 1.0 Subject: Re: [PATCH] ShellPkg/UefiHandleParsingLib: Fix memory leak X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 May 2017 15:17:36 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jaben Carsey > -----Original Message----- > From: Ni, Ruiyu > Sent: Tuesday, May 02, 2017 2:34 AM > To: edk2-devel@lists.01.org > Cc: Chen, Chen A ; Carsey, Jaben > > Subject: [PATCH] ShellPkg/UefiHandleParsingLib: Fix memory leak > Importance: High >=20 > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Ruiyu Ni > Signed-off-by: Chen A Chen > Cc: Jaben Carsey > --- > ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) >=20 > diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c > b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c > index c368d8cb21..da1d92fd17 100644 > --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c > +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.c > @@ -2331,7 +2331,9 @@ ConvertHandleIndexToHandle( > // Verify that LinkWalker->TheHandle is valid handle > // > Status =3D gBS->ProtocolsPerHandle(ListWalker->TheHandle, > &ProtocolBuffer, &ProtocolCount); > - if (EFI_ERROR (Status)) { > + if (!EFI_ERROR (Status)) { > + FreePool (ProtocolBuffer); > + } else { > // > // TheHandle is not valid, so do not add to handle list > // > -- > 2.12.2.windows.2