Skip to contentSkip to conversation

drm: rcar-du: Reduce of_node_put(cmm) calls in rcar_du_cmm_init()

PATCH New Markus Elfring 1 participant 1 message Oct 3, 2024

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

PATCH 1/1 drm: rcar-du: Reduce of_node_put(cmm) calls in rcar_du_cmm_init()

From: Markus Elfring <[email protected]>
Date: Thu, 3 Oct 2024 19:56:29 +0200

An of_node_put(cmm) call was immediately used after a null pointer check for an of_find_device_by_node() call in this function implementation. Thus call such a function instead directly before the check.

This issue was transformed by using the Coccinelle software.

---
 drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c +1 -3
index 70d8ad065bfa..a854b2b085f9 100644
@@ -792,14 +792,12 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu)
 		}
 
 		pdev = of_find_device_by_node(cmm);
+		of_node_put(cmm);
 		if (!pdev) {
 			dev_err(rcdu->dev, "No device found for CMM%u\n", i);
-			of_node_put(cmm);
 			return -EINVAL;
 		}
 
-		of_node_put(cmm);
-
 		/*
 		 * -ENODEV is used to report that the CMM config option is
 		 * disabled: return 0 and let the DU continue probing.

--
2.46.1