]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
timekeeping: Fix resource leak in tk_aux_sysfs_init() error paths
authorMalaya Kumar Rout <mrout@redhat.com>
Thu, 20 Nov 2025 15:02:13 +0000 (20:32 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 1 Dec 2025 10:46:00 +0000 (11:46 +0100)
commit0bd5502efdab2ca4d41c3dff9460fedc93c11d20
treea5daba0ad073cc214c8ca1fc0337f43c7279d13c
parentab6b19f690d89ae4709fba73a3c4a7911f495b7a
timekeeping: Fix resource leak in tk_aux_sysfs_init() error paths

[ Upstream commit 7b5ab04f035f829ed6008e4685501ec00b3e73c9 ]

tk_aux_sysfs_init() returns immediately on error during the auxiliary clock
initialization loop without cleaning up previously allocated kobjects and
sysfs groups.

If kobject_create_and_add() or sysfs_create_group() fails during loop
iteration, the parent kobjects (tko and auxo) and any previously created
child kobjects are leaked.

Fix this by adding proper error handling with goto labels to ensure all
allocated resources are cleaned up on failure. kobject_put() on the
parent kobjects will handle cleanup of their children.

Fixes: 7b95663a3d96 ("timekeeping: Provide interface to control auxiliary clocks")
Signed-off-by: Malaya Kumar Rout <mrout@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://patch.msgid.link/20251120150213.246777-1-mrout@redhat.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/time/timekeeping.c