Skip to content

Commit b593c0c

Browse files
uefi: Fix handling of a null interface pointer in boot::open_protocol
1 parent cce789a commit b593c0c

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

uefi/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ details of the deprecated items that were removed in this release.
1010
- **Breaking:** `FileSystem` no longer has a lifetime parameter, and the
1111
deprecated conversion from `uefi::table::boot::ScopedProtocol` has been
1212
removed.
13+
- Fixed `boot::open_protocol` to properly handle a null interface pointer.
1314

1415

1516
# uefi - 0.32.0 (2024-09-09)

uefi/src/boot.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -969,9 +969,16 @@ pub unsafe fn open_protocol<P: ProtocolPointer + ?Sized>(
969969
Handle::opt_to_ptr(params.controller),
970970
attributes as u32,
971971
)
972-
.to_result_with_val(|| ScopedProtocol {
973-
interface: NonNull::new(P::mut_ptr_from_ffi(interface)),
974-
open_params: params,
972+
.to_result_with_val(|| {
973+
let interface = if interface.is_null() {
974+
None
975+
} else {
976+
NonNull::new(P::mut_ptr_from_ffi(interface))
977+
};
978+
ScopedProtocol {
979+
interface,
980+
open_params: params,
981+
}
975982
})
976983
}
977984

0 commit comments

Comments
 (0)