]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
cpuidle: Fix kobject memory leaks in error paths
authorAnel Orazgaliyeva <anelkz@amazon.de>
Mon, 6 Sep 2021 18:34:40 +0000 (18:34 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 26 Nov 2021 10:36:08 +0000 (11:36 +0100)
commit22d44652b6d6404b96a40bb051d1046e6c005ae5
tree3f24be9840b62d37a8f45cb6c6701cdedf46ebc9
parent3b19077c7e1e81e5e0a0cb04a881151b3d0713e1
cpuidle: Fix kobject memory leaks in error paths

[ Upstream commit e5f5a66c9aa9c331da5527c2e3fd9394e7091e01 ]

Commit c343bf1ba5ef ("cpuidle: Fix three reference count leaks")
fixes the cleanup of kobjects; however, it removes kfree() calls
altogether, leading to memory leaks.

Fix those and also defer the initialization of dev->kobj_dev until
after the error check, so that we do not end up with a dangling
pointer.

Fixes: c343bf1ba5ef ("cpuidle: Fix three reference count leaks")
Signed-off-by: Anel Orazgaliyeva <anelkz@amazon.de>
Suggested-by: Aman Priyadarshi <apeureka@amazon.de>
[ rjw: Subject edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/cpuidle/sysfs.c