Skip to content

Commit 682e196

Browse files
cyrilbur-ibmstewartsmith
authored andcommitted
libflash/blocklevel: Correct miscalculation in blocklevel_smart_erase()
If blocklevel_smart_erase() detects that the smart erase fits entire in one erase block, it has an early bail path. In this path it miscaculates where in the buffer the backend needs to read from to perform the final write. Fixes: d6a5b53 ("libflash/blocklevel: Add blocklevel_smart_erase()") Fixes: #151 Reported-by: Pridhiviraj Paidipeddi <ppaidipe@linux.vnet.ibm.com> Tested-by: Pridhiviraj Paidipeddi <ppaidipe@linux.vnet.ibm.com> Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
1 parent f24db9e commit 682e196

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libflash/blocklevel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ int blocklevel_smart_erase(struct blocklevel_device *bl, uint64_t pos, uint64_t
348348
* so we need to write back the chunk at the end of the block
349349
*/
350350
if (base_pos + base_len + len < base_pos + block_size) {
351-
rc = bl->write(bl, pos + len, erase_buf + pos + len,
351+
rc = bl->write(bl, pos + len, erase_buf + base_len + len,
352352
block_size - base_len - len);
353353
FL_DBG("%s: Early exit, everything was in one erase block\n",
354354
__func__);

0 commit comments

Comments
 (0)