Skip to contentSkip to conversation

rtc: fix device_register() error handling

PATCH Applied Vasiliy Kulikov 1 participant 1 message Sep 19, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 9/14 rtc: fix device_register() error handling

If device_register() fails then call put_device(). See comment to device_register.

---
compile tested.

 drivers/rtc/class.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/rtc/class.c +3 -1
index 565562b..e6539cb 100644
@@ -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);
Signature · 1 line
1.7.0.4