bmc: lpc aspeed: add missing file open failure check
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I5440b54cb5b24618c8cf5d6a4d977a82f5b704dd
diff --git a/lpc_aspeed.cpp b/lpc_aspeed.cpp
index 7f111f2..364aff5 100644
--- a/lpc_aspeed.cpp
+++ b/lpc_aspeed.cpp
@@ -140,10 +140,13 @@
{
/* Open the file to map. */
mappedFd = sys->open(lpcControlPath.c_str(), O_RDONLY | O_SYNC);
+ if (mappedFd == -1)
+ {
+ std::fprintf(stderr, "ipmiflash: unable to open %s\n",
+ lpcControlPath.c_str());
+ return false;
+ }
- /* TODO: The offset to use is the address we use for the map - the base
- * address of the memory region we reserved in the device-tree.
- */
mappedRegion = reinterpret_cast<uint8_t*>(
sys->mmap(0, regionSize, PROT_READ, MAP_SHARED, mappedFd, 0));