Skip to content

Commit

Permalink
spdm: setup_transport_layer: propagate errors
Browse files Browse the repository at this point in the history
Signed-off-by: Wilfred Mallawa <[email protected]>
  • Loading branch information
twilfredo committed Jul 21, 2024
1 parent 4839f89 commit 277c765
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/libspdm/spdm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,16 +460,24 @@ pub unsafe fn setup_transport_layer(
data_ptr,
core::mem::size_of::<u32>(),
)) {
panic!("Unable to set data");
error!("Unable to set data");
return Err(());
}

let libspdm_scratch_buffer_size = libspdm_get_sizeof_required_scratch_buffer(context);
let libspdm_scratch_buffer_layout =
Layout::from_size_align(libspdm_scratch_buffer_size, 8).unwrap();
match Layout::from_size_align(libspdm_scratch_buffer_size, 8) {
Ok(layout) => layout,
Err(e) => {
error!("Failed to generate layout: {:?}", e);
return Err(());
}
};
let libspdm_scratch_buffer = alloc(libspdm_scratch_buffer_layout);

if libspdm_scratch_buffer.is_null() {
panic!("Unable to allocate libspdm scratch buffer");
error!("Unable to allocate libspdm scratch buffer");
return Err(());
}

let libspdm_scratch_buffer_ptr: *mut c_void = libspdm_scratch_buffer as *mut _ as *mut c_void;
Expand Down

0 comments on commit 277c765

Please sign in to comment.