All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bcm: pm-arm: add missing of_node_put before break and return
@ 2021-12-13  9:45 ` Qing Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Qing Wang @ 2021-12-13  9:45 UTC (permalink / raw)
  To: Florian Fainelli, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel
  Cc: Wang Qing

From: Wang Qing <wangqing@vivo.com>

Fix following coccicheck warning:
WARNING: Function "for_each_matching_node" 
should have of_node_put() before return.

Early exits from for_each_matching_node should decrement the
node reference counter.

Signed-off-by: Wang Qing <wangqing@vivo.com>
---
 drivers/soc/bcm/brcmstb/pm/pm-arm.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/bcm/brcmstb/pm/pm-arm.c b/drivers/soc/bcm/brcmstb/pm/pm-arm.c
index 3cbb165..caec114
--- a/drivers/soc/bcm/brcmstb/pm/pm-arm.c
+++ b/drivers/soc/bcm/brcmstb/pm/pm-arm.c
@@ -731,15 +731,19 @@ static int brcmstb_pm_probe(struct platform_device *pdev)
 	for_each_matching_node(dn, ddr_shimphy_dt_ids) {
 		i = ctrl.num_memc;
 		if (i >= MAX_NUM_MEMC) {
+			of_node_put(dn);
 			pr_warn("too many MEMCs (max %d)\n", MAX_NUM_MEMC);
 			break;
 		}
 
 		base = of_io_request_and_map(dn, 0, dn->full_name);
 		if (IS_ERR(base)) {
-			if (!ctrl.support_warm_boot)
+			if (!ctrl.support_warm_boot) {
+				of_node_put(dn);
 				break;
+			}
 
+			of_node_put(dn);
 			pr_err("error mapping DDR SHIMPHY %d\n", i);
 			return PTR_ERR(base);
 		}
@@ -752,6 +756,7 @@ static int brcmstb_pm_probe(struct platform_device *pdev)
 	for_each_matching_node(dn, brcmstb_memc_of_match) {
 		base = of_iomap(dn, 0);
 		if (!base) {
+			of_node_put(dn);
 			pr_err("error mapping DDR Sequencer %d\n", i);
 			return -ENOMEM;
 		}
@@ -759,6 +764,7 @@ static int brcmstb_pm_probe(struct platform_device *pdev)
 		of_id = of_match_node(brcmstb_memc_of_match, dn);
 		if (!of_id) {
 			iounmap(base);
+			of_node_put(dn);
 			return -EINVAL;
 		}
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] bcm: pm-arm: add missing of_node_put before break and return
@ 2021-12-13  9:45 ` Qing Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Qing Wang @ 2021-12-13  9:45 UTC (permalink / raw)
  To: Florian Fainelli, bcm-kernel-feedback-list, linux-arm-kernel,
	linux-kernel
  Cc: Wang Qing

From: Wang Qing <wangqing@vivo.com>

Fix following coccicheck warning:
WARNING: Function "for_each_matching_node" 
should have of_node_put() before return.

Early exits from for_each_matching_node should decrement the
node reference counter.

Signed-off-by: Wang Qing <wangqing@vivo.com>
---
 drivers/soc/bcm/brcmstb/pm/pm-arm.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/soc/bcm/brcmstb/pm/pm-arm.c b/drivers/soc/bcm/brcmstb/pm/pm-arm.c
index 3cbb165..caec114
--- a/drivers/soc/bcm/brcmstb/pm/pm-arm.c
+++ b/drivers/soc/bcm/brcmstb/pm/pm-arm.c
@@ -731,15 +731,19 @@ static int brcmstb_pm_probe(struct platform_device *pdev)
 	for_each_matching_node(dn, ddr_shimphy_dt_ids) {
 		i = ctrl.num_memc;
 		if (i >= MAX_NUM_MEMC) {
+			of_node_put(dn);
 			pr_warn("too many MEMCs (max %d)\n", MAX_NUM_MEMC);
 			break;
 		}
 
 		base = of_io_request_and_map(dn, 0, dn->full_name);
 		if (IS_ERR(base)) {
-			if (!ctrl.support_warm_boot)
+			if (!ctrl.support_warm_boot) {
+				of_node_put(dn);
 				break;
+			}
 
+			of_node_put(dn);
 			pr_err("error mapping DDR SHIMPHY %d\n", i);
 			return PTR_ERR(base);
 		}
@@ -752,6 +756,7 @@ static int brcmstb_pm_probe(struct platform_device *pdev)
 	for_each_matching_node(dn, brcmstb_memc_of_match) {
 		base = of_iomap(dn, 0);
 		if (!base) {
+			of_node_put(dn);
 			pr_err("error mapping DDR Sequencer %d\n", i);
 			return -ENOMEM;
 		}
@@ -759,6 +764,7 @@ static int brcmstb_pm_probe(struct platform_device *pdev)
 		of_id = of_match_node(brcmstb_memc_of_match, dn);
 		if (!of_id) {
 			iounmap(base);
+			of_node_put(dn);
 			return -EINVAL;
 		}
 
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-13 10:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-13  9:45 [PATCH] bcm: pm-arm: add missing of_node_put before break and return Qing Wang
2021-12-13  9:45 ` Qing Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.