[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20190121153431.24789-1-tiny.windzz@gmail.com>
Date: Mon, 21 Jan 2019 10:34:31 -0500
From: Yangtao Li <tiny.windzz@...il.com>
To: john.stultz@...aro.org, tglx@...utronix.de, sboyd@...nel.org
Cc: linux-kernel@...r.kernel.org, Yangtao Li <tiny.windzz@...il.com>
Subject: [PATCH] clocksource: decrement reference count when device_register() fail
device_register() may fail, use put_device() giving up the refconut
to avoid refcount leak.
Signed-off-by: Yangtao Li <tiny.windzz@...il.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
Powered by blists - more mailing lists