Commit 59cca865f21e9e7beab73fcf79ba4eb776a4c228

Authored by Vasiliy Kulikov
Committed by Linus Torvalds
1 parent d7c7ef908b

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 <segooon@gmail.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Wan ZongShun <mcuos.com@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 3 additions and 1 deletions Side-by-side Diff

... ... @@ -158,8 +158,10 @@
158 158 rtc_dev_prepare(rtc);
159 159  
160 160 err = device_register(&rtc->dev);
161   - if (err)
  161 + if (err) {
  162 + put_device(&rtc->dev);
162 163 goto exit_kfree;
  164 + }
163 165  
164 166 rtc_dev_add_device(rtc);
165 167 rtc_sysfs_add_device(rtc);