]> www.infradead.org Git - users/jedix/linux-maple.git/commit
rust: devres: fix leaking call to devm_add_action()
authorDanilo Krummrich <dakr@kernel.org>
Tue, 12 Aug 2025 13:09:06 +0000 (15:09 +0200)
committerDanilo Krummrich <dakr@kernel.org>
Wed, 13 Aug 2025 23:52:15 +0000 (01:52 +0200)
commit75a7b151e808355a1fdf972e85da137612b8f2ae
tree9b7a123aed21c54630294776051fd25b29905d67
parenta5ba9ad417254c49ecf06ac5ab36ec4b12ee133f
rust: devres: fix leaking call to devm_add_action()

When the data argument of Devres::new() is Err(), we leak the preceding
call to devm_add_action().

In order to fix this, call devm_add_action() in a unit type initializer in
try_pin_init!() after the initializers of all other fields.

Fixes: f5d3ef25d238 ("rust: devres: get rid of Devres' inner Arc")
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Link: https://lore.kernel.org/r/20250812130928.11075-1-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
rust/kernel/devres.rs