[RESEND PATCH] char/rtc: fix object reference leaks in rtc_init

From: Wen Yang
Date: Wed Jan 23 2019 - 20:35:52 EST


The device node iterators perform an of_node_get on each iteration, so a
jump out of the loop requires an of_node_put.
The of_find_device_by_node() takes a reference to the underlying device
structure, we also should release that reference.
This patch fixes those 2 issues.
Fixes: 75081322c ("sparc32: Convert PC RTC probing to pure OF driver")

Signed-off-by: Wen Yang <wen.yang99@xxxxxxxxxx>
Cc: Arnd Bergmann <arnd@xxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Cc: David S. Miller <davem@xxxxxxxxxxxxx>
Cc: linux-kernel@xxxxxxxxxxxxxxx
---
drivers/char/rtc.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c
index c862d0b..aa67690 100644
--- a/drivers/char/rtc.c
+++ b/drivers/char/rtc.c
@@ -872,6 +872,8 @@ static int __init rtc_init(void)
if (op) {
rtc_port = op->resource[0].start;
rtc_irq = op->irqs[0];
+ put_device(&op->dev);
+ of_node_put(dp);
goto found;
}
}
--
2.9.5