]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
rust: pwm: Fix potential memory leak on init error
authorKari Argillander <kari.argillander@gmail.com>
Fri, 2 Jan 2026 07:51:41 +0000 (09:51 +0200)
committerUwe Kleine-König <ukleinek@kernel.org>
Tue, 20 Jan 2026 17:49:58 +0000 (18:49 +0100)
commita2633dc243c35754a0c2270131d8a199c987c9bf
treede032ca43d7de586994e5ec9cdfd6c3dd5bb93e2
parentb0dc6c6e97101a5d17d18be62c39817f38590da3
rust: pwm: Fix potential memory leak on init error

When initializing a PWM chip using pwmchip_alloc(), the allocated device
owns an initial reference that must be released on all error paths.

If __pinned_init() were to fail, the allocated pwm_chip would currently
leak because the error path returns without calling pwmchip_put().

Fixes: 7b3dce814a15 ("rust: pwm: Add Kconfig and basic data structures")
Signed-off-by: Kari Argillander <kari.argillander@gmail.com>
Acked-by: Michal Wilczynski <m.wilczynski@samsung.com>
Link: https://patch.msgid.link/20260102-pwm-rust-v2-1-2702ce57d571@gmail.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
rust/kernel/pwm.rs