aboutsummaryrefslogtreecommitdiffstats
path: root/rust
diff options
authorWolfram Sang <wsa+renesas@sang-engineering.com>2026-06-08 09:47:50 +0200
committerWolfram Sang <wsa+renesas@sang-engineering.com>2026-06-08 09:47:50 +0200
commitb3f240cca1ec061afa1224b3a6e3b473b5b4f3e1 (patch)
tree71930def2edeb8a9534bc01d2c22c6d8c0951ec0 /rust
parent4549871118cf616eecdd2d939f78e3b9e1dddc48 (diff)
parent4eb422482ca5d924d7212ad2ca1cb7ea6f5b524d (diff)
downloadath-b3f240cca1ec061afa1224b3a6e3b473b5b4f3e1.tar.gz
Merge tag 'rust-i2c-7.1-rc7' of https://github.com/ikrtn/linux into i2c/for-current
rust: i2c: fix I2cAdapter refcount double increment
Diffstat (limited to 'rust')
-rw-r--r--rust/kernel/i2c.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/rust/kernel/i2c.rs b/rust/kernel/i2c.rs
index 7b908f0c5a58d..c084a45b1916c 100644
--- a/rust/kernel/i2c.rs
+++ b/rust/kernel/i2c.rs
@@ -405,7 +405,9 @@ impl I2cAdapter {
// SAFETY: `adapter` is non-null and points to a live `i2c_adapter`.
// `I2cAdapter` is #[repr(transparent)], so this cast is valid.
- Ok(unsafe { (&*adapter.as_ptr().cast::<I2cAdapter<device::Normal>>()).into() })
+ // `i2c_get_adapter` returned the adapter with an incremented refcount, which we pass to
+ // the `ARef`.
+ Ok(unsafe { ARef::from_raw(adapter.cast::<I2cAdapter<device::Normal>>()) })
}
}