Skip to content

Commit e55c21a

Browse files
Skallwarn1tram1CohenArthur
committed
Fix out of scope pointer to spi_driver_register
Co-authored-by: Skallwar <[email protected]> Co-authored-by: n1tram1 <[email protected]> Co-authored-by: CohenArthur <[email protected]>
1 parent 25809b7 commit e55c21a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

rust/kernel/spi.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ impl DriverRegistration {
7878
spi_driver.remove = self.remove;
7979
spi_driver.shutdown = self.shutdown;
8080

81-
let this = unsafe { self.get_unchecked_mut() };
81+
let mut this = unsafe { self.get_unchecked_mut() };
8282
if this.registered {
8383
return Err(Error::EINVAL);
8484
}
8585

8686
this.spi_driver = Some(spi_driver);
8787

88-
let res = unsafe { bindings::__spi_register_driver(this.this_module.0, &mut spi_driver) };
88+
let res = unsafe { bindings::__spi_register_driver(this.this_module.0, this.spi_driver.as_mut().unwrap()) };
8989

9090
match res {
9191
0 => {
@@ -99,7 +99,7 @@ impl DriverRegistration {
9999

100100
impl Drop for DriverRegistration {
101101
fn drop(&mut self) {
102-
unsafe { bindings::driver_unregister(&mut self.spi_driver.unwrap().driver) }
102+
unsafe { bindings::driver_unregister(&mut self.spi_driver.as_mut().unwrap().driver) }
103103
// FIXME: No unwrap? But it's safe?
104104
}
105105
}

0 commit comments

Comments
 (0)