From a18bc90164e4ce75f2b9f9cb05a6dadaf6953a4f Mon Sep 17 00:00:00 2001 From: Matthew Jackson <1085847+MattJackson@users.noreply.github.com> Date: Fri, 18 Sep 2026 09:52:27 -0700 Subject: [PATCH] freemkv: source the SET data-in buffer from MIN_ALLOC_LEN (single source for the transfer length) --- src/freemkv/mod.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/freemkv/mod.rs b/src/freemkv/mod.rs index 60a08c5..a72aa71 100644 --- a/src/freemkv/mod.rs +++ b/src/freemkv/mod.rs @@ -18,8 +18,8 @@ //! the migrated spec the HRL/AKE/BUS unlock direction is `STATE_OFF`, not `0x01`. use crate::firmware::{ - Feature, MEMREAD_LEN, REGION_FREE, RESP_MAGIC, SPEED_MAX, STATE_OFF, build_identity_cdb, - build_memread_cdb, build_set_cdb, + Feature, MEMREAD_LEN, MIN_ALLOC_LEN, REGION_FREE, RESP_MAGIC, SPEED_MAX, STATE_OFF, + build_identity_cdb, build_memread_cdb, build_set_cdb, }; use crate::scsi::{DataDirection, ScsiTransport}; use crate::{UnlockCtx, UnlockError, Unlocked, Unlocker}; @@ -99,10 +99,10 @@ impl FreemkvUnlocker { state: u8, ) -> std::result::Result<(), UnlockError> { let cdb = build_set_cdb(feature, state); - // SET needs the 64-byte data-in phase its CDB advertises — the drive aborts - // a no-data SET (CHECK CONDITION / Aborted Command, HW-confirmed on BU40N fw - // 0.8.1). Mirror FirmwareControl::set (exec_in): read the table back, ignore it. - let mut buf = [0u8; RESP_LEN]; + // SET needs the data-in phase its CDB advertises — a no-data SET is aborted + // (CHECK CONDITION, HW-confirmed on BU40N fw 0.8.1). Buffer sized from the SAME + // const the CDB advertises (MIN_ALLOC_LEN) so the transfer length has one source. + let mut buf = [0u8; MIN_ALLOC_LEN as usize]; match scsi.execute(&cdb, DataDirection::FromDevice, &mut buf, 5_000) { Ok(r) if r.status == 0 => Ok(()), Ok(r) => {