diff options
| author | Nicolás Antinori <nico.antinori.7@gmail.com> | 2026-05-31 15:23:07 -0300 |
|---|---|---|
| committer | Igor Korotin <igor.korotin@linux.dev> | 2026-06-06 15:19:27 +0100 |
| commit | 4eb422482ca5d924d7212ad2ca1cb7ea6f5b524d (patch) | |
| tree | 6e5fa0b5bd51aabb7adbca245b15cafa70780ef0 /net/bpfilter/git@git.tavy.me:linux.git | |
| parent | e43ffb69e0438cddd72aaa30898b4dc446f664f8 (diff) | |
rust: i2c: fix I2cAdapter refcounts double increment
When `I2cAdapter::get` executes, it first calls
`bindings::i2c_get_adapter()` which increments the device and module
reference counts. It then takes a reference to the raw pointer and
converts it to an `ARef` via `.into()`.
The implementation of `From<&T> for ARef<T>` where `T: AlwaysRefCounted`
unconditionally calls `T::inc_ref()`. This leads to a second increment
to the reference counts.
Since the returned `ARef` will only release a single reference when
dropped via `dec_ref()`, this leaks one device and module reference count
on every call.
This fix was suggested by sashiko.dev.
Link: https://sashiko.dev/#/patchset/20260521190937.248904-1-nico.antinori.7@gmail.com
Signed-off-by: Nicolás Antinori <nico.antinori.7@gmail.com>
Reviewed-by: Igor Korotin <igor.korotin@linux.dev>
Signed-off-by: Igor Korotin <igor.korotin@linux.dev>
Diffstat (limited to 'net/bpfilter/git@git.tavy.me:linux.git')
0 files changed, 0 insertions, 0 deletions
