From: "Zhang, Chao B" <chao.b.zhang@intel.com>
To: "Tian, Feng" <feng.tian@intel.com>
Cc: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: [patch] MdeModulePkg/FvSimpleFileSystem: fix assertions when FV is empty
Date: Tue, 2 Aug 2016 12:42:40 +0000 [thread overview]
Message-ID: <FF72C7E4248F3C4E9BDF19D4918E90F21140DCB3@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <69491d04c14e4b41c46497b85100eeb7b54c71ab.1470125313.git.feng.tian@intel.com>
Reviewed-by: Chao Zhang <chao.b.zhang@intel.com>
Thanks & Best regards
Chao Zhang
-----Original Message-----
From: Tian, Feng
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 <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Feng Tian <feng.tian@intel.com>
---
.../Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c | 9 +++++++--
.../FvSimpleFileSystemDxe/FvSimpleFileSystemEntryPoint.c | 6 +++++-
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.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);
- NewFile->DirReadNext = FVFS_GET_FIRST_FILE_INFO (Instance);
+ NewFile->DirReadNext = NULL;
+ if (!IsListEmpty (&Instance->FileInfoHead)) {
+ NewFile->DirReadNext = FVFS_GET_FIRST_FILE_INFO (Instance);
+ }
*NewHandle = &NewFile->FileProtocol;
return EFI_SUCCESS;
@@ -821,7 +824,9 @@ FvSimpleFileSystemSetPosition (
//
// Reset directory position to first entry
//
- File->DirReadNext = FVFS_GET_FIRST_FILE_INFO (Instance);
+ if (File->DirReadNext) {
+ File->DirReadNext = FVFS_GET_FIRST_FILE_INFO (Instance);
+ }
} else if (Position == 0xFFFFFFFFFFFFFFFFull) {
File->Position = File->FvFileInfo->FileInfo.FileSize;
} else {
diff --git a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemEntryPoint.c b/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemEntryPoint.c
index 7167fb9..4e6089b 100644
--- a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemEntryPoint.c
+++ b/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemEntryPoint.c
@@ -223,7 +223,11 @@ FvSimpleFileSystemOpenVolume (
}
}
- Instance->Root->DirReadNext = FVFS_GET_FIRST_FILE_INFO (Instance);
+ Instance->Root->DirReadNext = NULL;
+ if (!IsListEmpty (&Instance->FileInfoHead)) {
+ Instance->Root->DirReadNext = FVFS_GET_FIRST_FILE_INFO (Instance);
+ }
+
*RootFile = &Instance->Root->FileProtocol;
return Status;
}
--
2.7.1.windows.2
prev parent reply other threads:[~2016-08-02 12:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-02 8:09 [patch] MdeModulePkg/FvSimpleFileSystem: fix assertions when FV is empty Feng Tian
2016-08-02 12:42 ` Zhang, Chao B [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=FF72C7E4248F3C4E9BDF19D4918E90F21140DCB3@shsmsx102.ccr.corp.intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox