diff mbox series

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

Message ID 20201113100850.GA168908@mwanda
State New
Headers show
Series soc: aspeed: Fix a reference leak in aspeed_socinfo_init() | expand

Commit Message

Dan Carpenter Nov. 13, 2020, 10:08 a.m. UTC
This needs to call of_node_put(np) before returning if of_iomap() fails.

Fixes: e0218dca5787 ("soc: aspeed: Add soc info driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/soc/aspeed/aspeed-socinfo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Andrew Jeffery Nov. 16, 2020, 4:10 a.m. UTC | #1
On Fri, 13 Nov 2020, at 20:38, Dan Carpenter wrote:
> This needs to call of_node_put(np) before returning if of_iomap() fails.
> 
> Fixes: e0218dca5787 ("soc: aspeed: Add soc info driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
diff mbox series

Patch

diff --git a/drivers/soc/aspeed/aspeed-socinfo.c b/drivers/soc/aspeed/aspeed-socinfo.c
index 20a1d4aeb051..773930e0cb10 100644
--- a/drivers/soc/aspeed/aspeed-socinfo.c
+++ b/drivers/soc/aspeed/aspeed-socinfo.c
@@ -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);