Skip to content

Commit

Permalink
PM / sleep: fix device reference leak in test_suspend
Browse files Browse the repository at this point in the history
Make sure to drop the reference taken by class_find_device() after
opening the RTC device.

Fixes: 77437fd (pm: boot time suspend selftest)
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Johan Hovold authored and Rafael J. Wysocki committed Nov 2, 2016
1 parent a909d3e commit ceb7578
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion kernel/power/suspend_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,10 @@ static int __init test_suspend(void)

/* RTCs have initialized by now too ... can we use one? */
dev = class_find_device(rtc_class, NULL, NULL, has_wakealarm);
if (dev)
if (dev) {
rtc = rtc_class_open(dev_name(dev));
put_device(dev);
}
if (!rtc) {
printk(warn_no_rtc);
return 0;
Expand Down

0 comments on commit ceb7578

Please sign in to comment.