Skip to contentSkip to conversation

fsi: master-hub: Fix of_node reference leak in hub_master_probe()

PATCH New Wentao Liang 1 participant 1 message Sep 16

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

PATCH 1/1 fsi: master-hub: Fix of_node reference leak in hub_master_probe()

In hub_master_probe(), a reference to the device tree node is taken with of_node_get() and stored in master.dev.of_node. If fsi_master_register() fails, the error path releases the link range without putting that reference, leaking it.

Put the device node reference before returning on the error path, so that the kzalloc() failure path, which runs before the node reference is taken, is unaffected.

Fixes f6a2f8eb73f0 ("fsi: Match fsi slaves and engines to available dt nodes")
---
 drivers/fsi/fsi-master-hub.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/fsi/fsi-master-hub.c +3 -1
index e5ac9025762e..9507caa78358 100644
@@ -240,8 +240,10 @@ static int hub_master_probe(struct fsi_device *fsi_dev)
 	hub_master_init(hub);
 
 	rc = fsi_master_register(&hub->master);
-	if (rc)
+	if (rc) {
+		of_node_put(hub->master.dev.of_node);
 		goto err_release;
+	}
 
 	/* At this point, fsi_master_register performs the device_initialize(),
 	 * and holds the sole reference on master.dev. This means the device
Signature · 1 line
2.34.1