From: Vasiliy Kulikov Date: Wed, 27 Oct 2010 22:33:04 +0000 (-0700) Subject: drivers/rtc/class.c: fix device_register() error handling X-Git-Tag: MMI-PSA29.97-13-9~21932^2~130 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=59cca865f21e9e7beab73fcf79ba4eb776a4c228;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git drivers/rtc/class.c: fix device_register() error handling If device_register() fails then call put_device(). See comment to device_register. Signed-off-by: Vasiliy Kulikov Cc: Alessandro Zummo Cc: Wan ZongShun Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c index 565562ba6ac9..e6539cbabb35 100644 --- a/drivers/rtc/class.c +++ b/drivers/rtc/class.c @@ -158,8 +158,10 @@ struct rtc_device *rtc_device_register(const char *name, struct device *dev, rtc_dev_prepare(rtc); err = device_register(&rtc->dev); - if (err) + if (err) { + put_device(&rtc->dev); goto exit_kfree; + } rtc_dev_add_device(rtc); rtc_sysfs_add_device(rtc);