lkml.org 
[lkml]   [2019]   [Jan]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] clocksource: decrement reference count when device_register() fail
Date
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/clocksource.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index 3bcc19ceb073..0a830fedc7ef 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -1183,8 +1183,11 @@ static int __init init_clocksource_sysfs(void)
{
int error = subsys_system_register(&clocksource_subsys, NULL);

- if (!error)
+ if (!error) {
error = device_register(&device_clocksource);
+ if (error)
+ put_device(&device_clocksource);
+ }

return error;
}
--
2.17.0
\
 
 \ /
  Last update: 2019-01-21 16:36    [W:0.019 / U:52.216 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site