diff options
author | Deepak Kodihalli <dkodihal@in.ibm.com> | 2017-07-12 04:44:41 -0500 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2017-07-19 23:00:24 +0000 |
commit | b100fb8efd0baca49996b4340c31a3c7b7fe2de9 (patch) | |
tree | 63293b61f9d344de88c6b65487abf758cd3e7716 /mboxd_flash_virtual.cpp | |
parent | 7ee307c7e88ba0c1aae1791e95c2573c6b1e62cb (diff) | |
download | phosphor-mboxd-b100fb8efd0baca49996b4340c31a3c7b7fe2de9.tar.gz phosphor-mboxd-b100fb8efd0baca49996b4340c31a3c7b7fe2de9.zip |
vpnor copy_flash: remove incorrect size check
Remove a read window size check, which essentially mandated that a pnor
partition is at least as large as the window size.
To elaborate, the current mbox implementation assumes a read window size
of 1M. This is as per protocol; a host can even send a read size of 0,
the BMC implementation is responsible for reading what's valid and fits
in the window, and inform host about the size read. There was a check
which would see that a read size of 1M past the requested flash offset
is larger than an actual partition file size (for partitions < 1M), and
would fail the read request. Instead, in such a case, read the entire
partition and inform host about the size read.
Change-Id: I07d4b24d7eb31c5473c4142e96743d8f8d0e08a2
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
Diffstat (limited to 'mboxd_flash_virtual.cpp')
-rw-r--r-- | mboxd_flash_virtual.cpp | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/mboxd_flash_virtual.cpp b/mboxd_flash_virtual.cpp index 182278b..fb4075f 100644 --- a/mboxd_flash_virtual.cpp +++ b/mboxd_flash_virtual.cpp @@ -176,18 +176,10 @@ int64_t copy_flash(struct mbox_context* context, uint32_t offset, void* mem, // then size of the partition file then throw error. uint32_t baseOffset = partitionInfo->data.base << context->block_size_shift; - - if ((offset + size) > (baseOffset + partitionInfo->data.actual)) - { - MSG_ERR("Offset is beyond the partition file length[0x%.8x]\n", - partitionInfo->data.actual); - munmap(mapped_mem, partitionInfo->data.actual); - elog<InternalFailure>(); - } - //copy to the reserved memory area auto diffOffset = offset - baseOffset; - memcpy(mem, (char*)mapped_mem + diffOffset , size); + rc = std::min(partitionInfo->data.actual - diffOffset, size); + memcpy(mem, (char*)mapped_mem + diffOffset , rc); munmap(mapped_mem, partitionInfo->data.actual); } } |