[PATCH] firmware: arm_scmi: Avoid leak OF node on error

cgel.zte at gmail.com cgel.zte at gmail.com
Mon May 23 04:11:16 PDT 2022


From: Minghao Chi <chi.minghao at zte.com.cn>

The OF node should be put before returning error in smc_chan_available(),
otherwise node's refcount will be leaked.

Reported-by: Zeal Robot <zealci at zte.com.cn>
Signed-off-by: Minghao Chi <chi.minghao at zte.com.cn>
---
 drivers/firmware/arm_scmi/smc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c
index 745acfdd0b3d..43018be70edc 100644
--- a/drivers/firmware/arm_scmi/smc.c
+++ b/drivers/firmware/arm_scmi/smc.c
@@ -55,10 +55,10 @@ static irqreturn_t smc_msg_done_isr(int irq, void *data)
 static bool smc_chan_available(struct device *dev, int idx)
 {
 	struct device_node *np = of_parse_phandle(dev->of_node, "shmem", 0);
+	of_node_put(np);
 	if (!np)
 		return false;
 
-	of_node_put(np);
 	return true;
 }
 
-- 
2.25.1





More information about the linux-arm-kernel mailing list