[PATCH] gpu: ipu-v3: common: Add of_node_put() for reference returned by of_graph_get_port_by_id()
Liang He
windhl at 126.com
Wed Jul 20 15:22:27 UTC 2022
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")
Signed-off-by: Liang He <windhl at 126.com>
---
In fact, there may be another problem in following code:
'reg->pdata.of_node = of_node;'
'ret = platform_device_add_data(pdev, ®->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(+)
diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c
index 118318513e2d..c35eac1116f5 100644
--- a/drivers/gpu/ipu-v3/ipu-common.c
+++ b/drivers/gpu/ipu-v3/ipu-common.c
@@ -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;
}
--
2.25.1
More information about the dri-devel
mailing list