linux/drivers/powercap
Joe Hattori 4a2ea3dd4e powercap: call put_device() on an error path in powercap_register_control_type()
[ Upstream commit 93c66fbc28 ]

powercap_register_control_type() calls device_register(), but does not
release the refcount of the device when it fails.

Call put_device() before returning an error to balance the refcount.

Since the kfree(control_type) will be done by powercap_release(), remove
the lines in powercap_register_control_type() before returning the error.

This bug was found by an experimental verifier that I am developing.

Signed-off-by: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp>
Link: https://patch.msgid.link/20250110010554.1583411-1-joe@pf.is.s.u-tokyo.ac.jp
[ rjw: Changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2025-04-10 14:31:50 +02:00
..
dtpm.c powercap/drivers/dtpm: Fix root node initialization 2021-03-01 17:43:29 +01:00
dtpm_cpu.c powercap/drivers/dtpm: Fix size of object being allocated 2021-01-07 18:16:03 +01:00
idle_inject.c powercap: include header to fix -Wmissing-prototypes 2020-09-25 16:46:01 +02:00
intel_rapl_common.c powercap: intel_rapl: fix UBSAN shift-out-of-bounds issue 2022-10-26 12:35:30 +02:00
intel_rapl_msr.c powercap: RAPL: fix invalid initialization for pl4_supported field 2024-10-17 15:11:09 +02:00
Kconfig powercap: RAPL: Fix CONFIG_IOSF_MBI dependency 2023-07-23 13:46:46 +02:00
Makefile powercap/drivers/dtpm: Add CPU energy model based support 2020-12-22 19:50:40 +01:00
powercap_sys.c powercap: call put_device() on an error path in powercap_register_control_type() 2025-04-10 14:31:50 +02:00