[PATCH] video: fbdev: Fix refcount leak bug in valkyriefb.c
From: Liang He
Date: Fri Jun 17 2022 - 22:57:17 EST
In valkyriefb_init(), of_find_node_by_name() will return a node pointer
with refcount incremented. We should use of_node_put() in fail path or
when it is not used anymore.
Signed-off-by: Liang He <windhl@xxxxxxx>
---
drivers/video/fbdev/valkyriefb.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/video/fbdev/valkyriefb.c b/drivers/video/fbdev/valkyriefb.c
index a6c9d4f26669..20d727a8069d 100644
--- a/drivers/video/fbdev/valkyriefb.c
+++ b/drivers/video/fbdev/valkyriefb.c
@@ -334,10 +334,13 @@ int __init valkyriefb_init(void)
return 0;
if (of_address_to_resource(dp, 0, &r)) {
+ of_node_put(dp);
printk(KERN_ERR "can't find address for valkyrie\n");
return 0;
}
+ of_node_put(dp);
+
frame_buffer_phys = r.start;
cmap_regs_phys = r.start + 0x304000;
}
--
2.25.1