Skip to contentSkip to conversation

gpu: ipu-v3: common: Add of_node_put() for reference returned by of_graph_get_port_by_id()

PATCH Applied Liang He 2 participants 3 messages Jul 20, 2022 – Dec 16, 2022

Subsystems (2)
lore
Share & tools
lore

Liang He

author
#0 lore raw

PATCH 1/1 gpu: ipu-v3: common: Add of_node_put() for reference returned by of_graph_get_port_by_id()

In ipu_add_client_devices(), we need to call of_node_put() for reference returned by of_graph_get_port_by_id() in fail path.

Fixes 17e052175039 ("gpu: ipu-v3: Do not bail out on missing optional port nodes")

---
In fact, there may be another problem in following code:
'reg->pdata.of_node = of_node;'
'ret = platform_device_add_data(pdev, &reg->pdata,

		       sizeof(reg->pdata));'

The prolbem is that the 'of_node' will first escape into global 'reg (i.e., client_reg)' and then 'kmemdup' into 'pdev->dev.platform_data', so there are totally two copies of the reference 'of_node'.
I do not know if there is any problems as I do not know the whole picture of 'platform_device_*'.

As a result, I can only give a fix, adding the of_node_put().

 drivers/gpu/ipu-v3/ipu-common.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/ipu-v3/ipu-common.c +1 -0
index 118318513e2d..c35eac1116f5 100644
@@ -1165,6 +1165,7 @@ static int ipu_add_client_devices(struct ipu_soc *ipu, unsigned long ipu_base)
 		pdev = platform_device_alloc(reg->name, id++);
 		if (!pdev) {
 			ret = -ENOMEM;
+			of_node_put(of_node);
 			goto err_register;
 		}
 
Signature · 1 line
2.25.1
maintainer Applied
#2 lore raw
In reply to Liang He
Quoted 5 lines · Liang He

In ipu_add_client_devices(), we need to call of_node_put() for reference returned by of_graph_get_port_by_id() in fail path.

Fixes 17e052175039 ("gpu: ipu-v3: Do not bail out on missing optional port nodes")

Applied to drm-misc-next.

regards
Philipp