From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by ml01.01.org (Postfix) with ESMTP id ECD791A1E04 for ; Tue, 2 Aug 2016 05:42:42 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 02 Aug 2016 05:42:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,460,1464678000"; d="scan'208";a="1006966535" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga001.jf.intel.com with ESMTP; 02 Aug 2016 05:42:43 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 2 Aug 2016 05:42:42 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.147]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.116]) with mapi id 14.03.0248.002; Tue, 2 Aug 2016 20:42:40 +0800 From: "Zhang, Chao B" To: "Tian, Feng" CC: "edk2-devel@lists.01.org" Thread-Topic: [patch] MdeModulePkg/FvSimpleFileSystem: fix assertions when FV is empty Thread-Index: AQHR7JU6fHpR3Fd+nkaBDlocArvRgKA1nULw Date: Tue, 2 Aug 2016 12:42:40 +0000 Message-ID: References: <69491d04c14e4b41c46497b85100eeb7b54c71ab.1470125313.git.feng.tian@intel.com> In-Reply-To: <69491d04c14e4b41c46497b85100eeb7b54c71ab.1470125313.git.feng.tian@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOGYxNGQ4MDUtYmNjMS00MDA0LTlmZTAtNjdhNTdlY2U0YzJhIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IndKalRTQU1cLzNKN1lJNmhLYjZnUlg4SjFGaGwrZlJNb3V5cGNhOEVzZURBPSJ9 x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [patch] MdeModulePkg/FvSimpleFileSystem: fix assertions when FV is empty X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Aug 2016 12:42:43 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Chao Zhang Thanks & Best regards Chao Zhang -----Original Message----- From: Tian, Feng=20 Sent: Tuesday, August 02, 2016 4:10 PM To: Zhang, Chao B Cc: edk2-devel@lists.01.org Subject: [patch] MdeModulePkg/FvSimpleFileSystem: fix assertions when FV is= empty The original code will assert when dealing with those empty FVs. The fix is used to solve this bug. Cc: Chao Zhang Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Feng Tian --- .../Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c | 9 +++++= ++-- .../FvSimpleFileSystemDxe/FvSimpleFileSystemEntryPoint.c | 6 +++++= - 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSyste= m.c b/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c index c6137ac..b81110f 100644 --- a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c +++ b/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c @@ -526,7 +526,10 @@ FvSimpleFileSystemOpen ( InitializeListHead (&NewFile->Link); InsertHeadList (&Instance->FileHead, &NewFile->Link); =20 - NewFile->DirReadNext =3D FVFS_GET_FIRST_FILE_INFO (Instance); + NewFile->DirReadNext =3D NULL; + if (!IsListEmpty (&Instance->FileInfoHead)) { + NewFile->DirReadNext =3D FVFS_GET_FIRST_FILE_INFO (Instance); + } =20 *NewHandle =3D &NewFile->FileProtocol; return EFI_SUCCESS; @@ -821,7 +824,9 @@ FvSimpleFileSystemSetPosition ( // // Reset directory position to first entry // - File->DirReadNext =3D FVFS_GET_FIRST_FILE_INFO (Instance); + if (File->DirReadNext) { + File->DirReadNext =3D FVFS_GET_FIRST_FILE_INFO (Instance);=20 + } } else if (Position =3D=3D 0xFFFFFFFFFFFFFFFFull) { File->Position =3D File->FvFileInfo->FileInfo.FileSize; } else { diff --git a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSyste= mEntryPoint.c b/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSy= stemEntryPoint.c index 7167fb9..4e6089b 100644 --- a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemEntryP= oint.c +++ b/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemEntryP= oint.c @@ -223,7 +223,11 @@ FvSimpleFileSystemOpenVolume ( } } =20 - Instance->Root->DirReadNext =3D FVFS_GET_FIRST_FILE_INFO (Instance); + Instance->Root->DirReadNext =3D NULL; + if (!IsListEmpty (&Instance->FileInfoHead)) { + Instance->Root->DirReadNext =3D FVFS_GET_FIRST_FILE_INFO (Instance); + } + *RootFile =3D &Instance->Root->FileProtocol; return Status; } --=20 2.7.1.windows.2