aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/rtc/class.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2015-07-20 16:02:50 -0700
committerAlexandre Belloni <alexandre.belloni@free-electrons.com>2015-09-05 13:19:07 +0200
commitc3b399a4b6703a04ef6eb3efe35ff12163e409e0 (patch)
treecba87c8b65243980ee3d2cef8a68d621ad74b2f8 /drivers/rtc/class.c
parentrtc: class: fix double free in rtc_register_device() error path (diff)
downloadwireguard-linux-c3b399a4b6703a04ef6eb3efe35ff12163e409e0.tar.xz
wireguard-linux-c3b399a4b6703a04ef6eb3efe35ff12163e409e0.zip
rtc: class: remove unnecessary device_get() in rtc_device_unregister
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> Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Diffstat (limited to 'drivers/rtc/class.c')
-rw-r--r--drivers/rtc/class.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
index eb82ec2a21bd..de7707f7e766 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);