@@ -129,7 +129,7 @@ pub struct BootServices {
129
129
130
130
// Protocol handlers
131
131
install_protocol_interface : unsafe extern "efiapi" fn (
132
- handle : Option < & Handle > ,
132
+ handle : NonNull < Option < Handle > > ,
133
133
guid : & Guid ,
134
134
interface_type : InterfaceType ,
135
135
interface : Option < NonNull < c_void > > ,
@@ -633,8 +633,8 @@ impl BootServices {
633
633
}
634
634
}
635
635
636
- /// Installs a protocol interface on a device handle. If ` handle` is `None`, one will be
637
- /// created and added to the list of handles in the system and then returned.
636
+ /// Installs a protocol interface on a device handle. If the inner `Option` in ` handle` is `None`,
637
+ /// one will be created and added to the list of handles in the system and then returned."
638
638
///
639
639
/// When a protocol interface is installed, firmware will call all functions that have registered
640
640
/// to wait for that interface to be installed.
@@ -644,19 +644,23 @@ impl BootServices {
644
644
/// The caller is responsible for ensuring that they pass a valid `Guid` for `protocol`.
645
645
pub unsafe fn install_protocol_interface (
646
646
& self ,
647
- handle : Option < & Handle > ,
647
+ mut handle : Option < Handle > ,
648
648
protocol : & Guid ,
649
649
interface : Option < NonNull < c_void > > ,
650
650
) -> Result < Handle > {
651
+ // Safety: The given pointer is guaranteed to be non-null, even though what it's indirectly pointing to
652
+ // may be null, thus this is safe
653
+ let handle_ptr = NonNull :: new ( & mut handle as * mut _ ) . unwrap_unchecked ( ) ;
654
+
651
655
( ( self . install_protocol_interface ) (
652
- handle ,
656
+ handle_ptr ,
653
657
protocol,
654
658
InterfaceType :: NATIVE_INTERFACE ,
655
659
interface,
656
660
) )
657
661
// this `unwrapped_unchecked` is safe, `handle` is guaranteed to be Some() if this call is
658
662
// successful
659
- . into_with_val ( || * handle. unwrap_unchecked ( ) )
663
+ . into_with_val ( || handle. unwrap_unchecked ( ) )
660
664
}
661
665
662
666
/// Reinstalls a protocol interface on a device handle. `old_interface` is replaced with `new_interface`.
0 commit comments