From: Dan Carpenter <dan.carpenter@linaro.org>
To: Malaya Kumar Rout <mrout@redhat.com>
Cc: John Stultz <jstultz@google.com>,
Thomas Gleixner <tglx@linutronix.de>,
Stephen Boyd <sboyd@kernel.org>,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] timekeeping: Fix error code in tk_aux_sysfs_init()
Date: Tue, 25 Nov 2025 16:55:19 +0300 [thread overview]
Message-ID: <aSW1R8q5zoY_DgQE@stanley.mountain> (raw)
If kobject_create_and_add() fails on the first iteration, then the
error code is set to -ENOMEM and that's good. But if it fails on the
later 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>
---
kernel/time/timekeeping.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 0c8b77ee4a3a..3ec3daa4acab 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -3087,8 +3087,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)
--
2.51.0
next reply other threads:[~2025-11-25 13:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-25 13:55 Dan Carpenter [this message]
2025-11-25 14:17 ` [PATCH] timekeeping: Fix error code in tk_aux_sysfs_init() Malaya Kumar Rout
2025-11-25 16:56 ` [tip: timers/urgent] " tip-bot2 for Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aSW1R8q5zoY_DgQE@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=jstultz@google.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mrout@redhat.com \
--cc=sboyd@kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox