[PATCH] net: dpaa2-mac: add missing of_node_put() in dpaa2_mac_get_node()
From: Yang Yingliang
Date: Thu Apr 28 2022 - 06:00:01 EST
Add missing of_node_put() in error path in dpaa2_mac_get_node().
Fixes: 5b1e38c0792c ("dpaa2-mac: bail if the dpmacs fwnode is not found")
Reported-by: Hulk Robot <hulkci@xxxxxxxxxx>
Signed-off-by: Yang Yingliang <yangyingliang@xxxxxxxxxx>
---
drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
index c48811d3bcd5..a91446685526 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
@@ -108,8 +108,11 @@ static struct fwnode_handle *dpaa2_mac_get_node(struct device *dev,
return ERR_PTR(-EPROBE_DEFER);
}
- if (!parent)
+ if (!parent) {
+ if (dpmacs)
+ of_node_put(dpmacs);
return NULL;
+ }
fwnode_for_each_child_node(parent, child) {
err = -EINVAL;
--
2.25.1