Skip to contentSkip to conversation

soc: aspeed: Fix a reference leak in aspeed_socinfo_init()

PATCH In review Dan Carpenter 2 participants 2 messages Nov 13, 2020 – Nov 16, 2020

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

PATCH 1/1 soc: aspeed: Fix a reference leak in aspeed_socinfo_init()

This needs to call of_node_put(np) before returning if of_iomap() fails.

Fixes e0218dca5787 ("soc: aspeed: Add soc info driver")
---
 drivers/soc/aspeed/aspeed-socinfo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/soc/aspeed/aspeed-socinfo.c +3 -1
index 20a1d4aeb051..773930e0cb10 100644
@@ -74,8 +74,10 @@ static int __init aspeed_socinfo_init(void)
 	}
 
 	reg = of_iomap(np, 0);
-	if (!reg)
+	if (!reg) {
+		of_node_put(np);
 		return -ENODEV;
+	}
 	siliconid = readl(reg);
 	iounmap(reg);
 
Signature · 1 line
2.28.0