From: Yangtao Li <tiny.windzz@gmail.com>
To: tglx@linutronix.de
Cc: linux-kernel@vger.kernel.org, Yangtao Li <tiny.windzz@gmail.com>
Subject: [PATCH] clockevents: decrement reference count when device_register() fail
Date: Mon, 21 Jan 2019 10:30:13 -0500 [thread overview]
Message-ID: <20190121153013.24681-1-tiny.windzz@gmail.com> (raw)
device_register() may fail, use put_device() giving up the refconut
to avoid refcount leak.
Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
---
kernel/time/clockevents.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 5e77662dd2d9..7b691dc97349 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -719,7 +719,9 @@ static __init int tick_broadcast_init_sysfs(void)
{
int err = device_register(&tick_bc_dev);
- if (!err)
+ if (err)
+ put_device(&tick_bc_dev);
+ else
err = device_create_file(&tick_bc_dev, &dev_attr_current_device);
return err;
}
@@ -746,8 +748,10 @@ static int __init tick_init_sysfs(void)
err = device_create_file(dev, &dev_attr_current_device);
if (!err)
err = device_create_file(dev, &dev_attr_unbind_device);
- if (err)
+ if (err) {
+ put_device(dev);
return err;
+ }
}
return tick_broadcast_init_sysfs();
}
--
2.17.0
reply other threads:[~2019-01-21 15:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20190121153013.24681-1-tiny.windzz@gmail.com \
--to=tiny.windzz@gmail.com \
--cc=linux-kernel@vger.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;
as well as URLs for NNTP newsgroup(s).