From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Alessandro Zummo <a.zummo@towertech.it>,
Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org
Subject: [PATCH 2/4] RTC: remove unnecessary device_get() in rtc_device_unregister
Date: Mon, 20 Jul 2015 16:02:50 -0700 [thread overview]
Message-ID: <1437433372-15425-2-git-send-email-dmitry.torokhov@gmail.com> (raw)
In-Reply-To: <1437433372-15425-1-git-send-email-dmitry.torokhov@gmail.com>
Technically the address of rtc->dev can never be NULL, so get_device()
can never fail. Also caller of rtc_device_unregister() supposed to be
the owner of the device and thus have a valid reference. Therefore
call to get_device() is not needed here.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/rtc/class.c | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
index eb82ec2..de7707f 100644
--- a/drivers/rtc/class.c
+++ b/drivers/rtc/class.c
@@ -266,19 +266,18 @@ EXPORT_SYMBOL_GPL(rtc_device_register);
*/
void rtc_device_unregister(struct rtc_device *rtc)
{
- if (get_device(&rtc->dev) != NULL) {
- mutex_lock(&rtc->ops_lock);
- /* remove innards of this RTC, then disable it, before
- * letting any rtc_class_open() users access it again
- */
- rtc_sysfs_del_device(rtc);
- rtc_dev_del_device(rtc);
- rtc_proc_del_device(rtc);
- device_unregister(&rtc->dev);
- rtc->ops = NULL;
- mutex_unlock(&rtc->ops_lock);
- put_device(&rtc->dev);
- }
+ mutex_lock(&rtc->ops_lock);
+ /*
+ * Remove innards of this RTC, then disable it, before
+ * letting any rtc_class_open() users access it again
+ */
+ rtc_sysfs_del_device(rtc);
+ rtc_dev_del_device(rtc);
+ rtc_proc_del_device(rtc);
+ device_del(&rtc->dev);
+ rtc->ops = NULL;
+ mutex_unlock(&rtc->ops_lock);
+ put_device(&rtc->dev);
}
EXPORT_SYMBOL_GPL(rtc_device_unregister);
--
2.4.3.573.g4eafbef
next prev parent reply other threads:[~2015-07-20 23:03 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-20 23:02 [PATCH 1/4] RTC: fix double free in rtc_register_device() error path Dmitry Torokhov
2015-07-20 23:02 ` Dmitry Torokhov [this message]
2015-07-21 0:39 ` [rtc-linux] [PATCH 2/4] RTC: remove unnecessary device_get() in rtc_device_unregister Krzysztof Kozlowski
2015-07-22 20:33 ` Alexandre Belloni
2015-07-20 23:02 ` [PATCH 3/4] RTC: properly manage lifetime of dev and cdev in rtc device Dmitry Torokhov
2015-07-21 0:54 ` [rtc-linux] " Krzysztof Kozlowski
2015-07-22 20:40 ` Alexandre Belloni
2015-07-20 23:02 ` [PATCH 4/4] RTC: switch to using is_visible() to control sysfs attributes Dmitry Torokhov
2015-07-21 1:21 ` [rtc-linux] " Krzysztof Kozlowski
2015-07-22 20:57 ` Alexandre Belloni
2015-07-22 21:44 ` Dmitry Torokhov
2015-07-23 0:40 ` Krzysztof Kozlowski
2015-07-22 20:53 ` Alexandre Belloni
2015-07-21 0:32 ` [rtc-linux] [PATCH 1/4] RTC: fix double free in rtc_register_device() error path Krzysztof Kozlowski
2015-07-21 0:42 ` Dmitry Torokhov
2015-07-22 20:32 ` Alexandre Belloni
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=1437433372-15425-2-git-send-email-dmitry.torokhov@gmail.com \
--to=dmitry.torokhov@gmail.com \
--cc=a.zummo@towertech.it \
--cc=alexandre.belloni@free-electrons.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rtc-linux@googlegroups.com \
/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