* [PATCH] clocksource: decrement reference count when device_register() fail
@ 2019-01-21 15:34 Yangtao Li
0 siblings, 0 replies; only message in thread
From: Yangtao Li @ 2019-01-21 15:34 UTC (permalink / raw)
To: john.stultz, tglx, sboyd; +Cc: linux-kernel, Yangtao Li
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2019-01-21 15:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-21 15:34 [PATCH] clocksource: decrement reference count when device_register() fail Yangtao Li
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.