[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20190121153013.24681-1-tiny.windzz@gmail.com>
Date: Mon, 21 Jan 2019 10:30:13 -0500
From: Yangtao Li <tiny.windzz@...il.com>
To: tglx@...utronix.de
Cc: linux-kernel@...r.kernel.org, Yangtao Li <tiny.windzz@...il.com>
Subject: [PATCH] clockevents: 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/clockevents.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 5e77662dd2d9..7b691dc97349 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -719,7 +719,9 @@ static __init int tick_broadcast_init_sysfs(void)
{
int err = device_register(&tick_bc_dev);
- if (!err)
+ if (err)
+ put_device(&tick_bc_dev);
+ else
err = device_create_file(&tick_bc_dev, &dev_attr_current_device);
return err;
}
@@ -746,8 +748,10 @@ static int __init tick_init_sysfs(void)
err = device_create_file(dev, &dev_attr_current_device);
if (!err)
err = device_create_file(dev, &dev_attr_unbind_device);
- if (err)
+ if (err) {
+ put_device(dev);
return err;
+ }
}
return tick_broadcast_init_sysfs();
}
--
2.17.0
Powered by blists - more mailing lists