Skip to content

Commit f7e8314

Browse files
committed
Fix read offset
1 parent 1ebf36e commit f7e8314

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

drv/cosmo-hf/src/apob.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -614,14 +614,12 @@ impl ApobState {
614614
// Read data from the lease into local storage
615615
let n = (data.len() - i).min(PAGE_SIZE_BYTES);
616616
let addr = read_slot
617-
.flash_addr(i.try_into().unwrap_lite())
617+
.flash_addr(u32::try_from(i as u64 + offset).unwrap_lite())
618618
.unwrap_lite();
619619

620-
// Read back the current data; it must be erased or match (for
621-
// idempotency)
620+
// Read back the current data, then write it to the lease
622621
drv.flash_read(addr, &mut &mut out_buf[..n])
623622
.map_err(|_| ApobReadError::ReadFailed)?;
624-
625623
data.write_range(i..(i + n), &out_buf[..n])
626624
.map_err(|_| ApobReadError::ReadFailed)?;
627625
}

0 commit comments

Comments
 (0)