From 59ce099b7b59e86f2cc8ffedd3c97143dfccd33c Mon Sep 17 00:00:00 2001 From: Jayanth Othayoth Date: Fri, 27 Oct 2017 00:45:53 -0500 Subject: Fix for mboxd segfault during flash read mboxd segfaults during flash read when there is no partition associated to the given offset within the flash size. Proposed fix is to generate elog instead of returning reference to zeroed out pnor_partition structure. Resolves openbmc/openbmc#2365 Change-Id: I98bed1c09588c386d9ea2510618bb27eaa6dfbe0 Signed-off-by: Jayanth Othayoth --- pnor_partition_table.cpp | 3 +++ pnor_partition_table.hpp | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pnor_partition_table.cpp b/pnor_partition_table.cpp index 71510a2..aa68750 100644 --- a/pnor_partition_table.cpp +++ b/pnor_partition_table.cpp @@ -218,6 +218,9 @@ const pnor_partition& Table::partition(size_t offset) const } } + MSG_ERR("Partition corresponding to offset %x not found", offset); + elog(); + static pnor_partition p{}; return p; } diff --git a/pnor_partition_table.hpp b/pnor_partition_table.hpp index 662fb76..1cabe23 100644 --- a/pnor_partition_table.hpp +++ b/pnor_partition_table.hpp @@ -134,8 +134,8 @@ class Table * * @param[in] offset - PNOR offset in bytes * - * @returns const reference to pnor_partition, if found, else a - * reference to a zeroed out pnor_partition structure. + * @returns const reference to pnor_partition, if found, else an + * exception will be thrown. */ const pnor_partition& partition(size_t offset) const; -- cgit v1.2.1