Shumin, You need to add "ShellInfoNode->Handle = NULL" after "EfiShellClose" otherwise "EfiShellFreeFileList" in line 2372 may hang on closing the file again.
> Status = ShellSearchHandle(NextFilePatternStart, > UnicodeCollation, ShellInfoNode->Handle, FileList, ShellInfoNode, MapName); > + EfiShellClose(ShellInfoNode->Handle); + ShellInfoNode->Handle = NULL; //*************** Regards, Ray -----Original Message----- From: Carsey, Jaben Sent: Tuesday, December 22, 2015 9:23 AM To: Qiu, Shumin <[email protected]>; [email protected] Cc: Ni, Ruiyu <[email protected]>; Carsey, Jaben <[email protected]> Subject: RE: [PATCH v2 3/4] ShellPkg: Fix memory leak in ShellProtocol. Reviewed-by: Jaben Carsey <[email protected]> > -----Original Message----- > From: Qiu, Shumin > Sent: Monday, December 21, 2015 7:19 AM > To: [email protected] > Cc: Qiu, Shumin <[email protected]>; Carsey, Jaben > <[email protected]>; Ni, Ruiyu <[email protected]> > Subject: [PATCH v2 3/4] ShellPkg: Fix memory leak in ShellProtocol. > Importance: High > > 1. Close unused file handle. > 2. Free the local allocated buffer function returned. > > Cc: Jaben Carsey <[email protected]> > Cc: Ruiyu Ni <[email protected]> > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Qiu Shumin <[email protected]> > Reviewed-by: Ruiyu Ni <[email protected]> > --- > ShellPkg/Application/Shell/ShellProtocol.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/ShellPkg/Application/Shell/ShellProtocol.c > b/ShellPkg/Application/Shell/ShellProtocol.c > index def3bd3..6d5fc1f 100644 > --- a/ShellPkg/Application/Shell/ShellProtocol.c > +++ b/ShellPkg/Application/Shell/ShellProtocol.c > @@ -1361,6 +1361,7 @@ EfiShellDeleteFileByName( > // > // now delete the file > // > + ShellFileHandleRemove(FileHandle); > return (ShellInfoObject.NewEfiShellProtocol->DeleteFile(FileHandle)); > } > > @@ -2338,6 +2339,7 @@ ShellSearchHandle( > // recurse with the next part of the pattern > // > Status = ShellSearchHandle(NextFilePatternStart, > UnicodeCollation, > ShellInfoNode->Handle, FileList, ShellInfoNode, MapName); > + EfiShellClose(ShellInfoNode->Handle); > } > } else if (!EFI_ERROR(Status)) { > // > @@ -2456,6 +2458,7 @@ EfiShellFindFiles( > ; PatternCurrentLocation++); > PatternCurrentLocation++; > Status = ShellSearchHandle(PatternCurrentLocation, gUnicodeCollation, > RootFileHandle, FileList, NULL, MapName); > + EfiShellClose(RootFileHandle); > } > FreePool(RootDevicePath); > } > @@ -3260,6 +3263,7 @@ EfiShellGetAlias( > > if (Volatile == NULL) { > GetVariable2 (AliasLower, &gShellAliasGuid, (VOID **)&AliasVal, NULL); > + FreePool(AliasLower); > return (AddBufferToFreeList(AliasVal)); > } > RetSize = 0; > @@ -3273,6 +3277,7 @@ EfiShellGetAlias( > if (RetVal != NULL) { > FreePool(RetVal); > } > + FreePool(AliasLower); > return (NULL); > } > if ((EFI_VARIABLE_NON_VOLATILE & Attribs) == > EFI_VARIABLE_NON_VOLATILE) { > -- > 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

