aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@linaro.org>2025-11-25 16:55:19 +0300
committerThomas Gleixner <tglx@linutronix.de>2025-11-25 17:52:24 +0100
commitc7418164b463056bf4327b6a2abe638b78250f13 (patch)
tree5246c720af7982f3b50af2261b133866dc663e43
parentac3fd01e4c1efce8f2c054cdeb2ddd2fc0fb150d (diff)
downloadtip-timers/urgent.tar.gz
timekeeping: Fix error code in tk_aux_sysfs_init()timers_urgent_for_v6.18_rc8timers-urgent-2025-12-01timers/urgent
If kobject_create_and_add() fails on the first iteration, then the error code is set to -ENOMEM which is correct. But if it fails in subsequent iterations then "ret" is zero, which means success, but it should be -ENOMEM. Set the error code to -ENOMEM correctly. Fixes: 7b5ab04f035f ("timekeeping: Fix resource leak in tk_aux_sysfs_init() error paths") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Malaya Kumar Rout <mrout@redhat.com> Link: https://patch.msgid.link/aSW1R8q5zoY_DgQE@stanley.mountain
-rw-r--r--kernel/time/timekeeping.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 08e0943b54da6f..4790da895203c2 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -3073,8 +3073,10 @@ static int __init tk_aux_sysfs_init(void)
char id[2] = { [0] = '0' + i, };
struct kobject *clk = kobject_create_and_add(id, auxo);
- if (!clk)
+ if (!clk) {
+ ret = -ENOMEM;
goto err_clean;
+ }
ret = sysfs_create_group(clk, &aux_clock_enable_attr_group);
if (ret)