Skip to contentSkip to conversation

drm/msm/a6xx: Fix refcount leak in a6xx_gpu_init

PATCH In review Miaoqian Lin 2 participants 2 messages May 12, 2022

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

PATCH 1/1 drm/msm/a6xx: Fix refcount leak in a6xx_gpu_init

of_parse_phandle() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore.

a6xx_gmu_init() passes the node to of_find_device_by_node() and of_dma_configure(), of_find_device_by_node() will takes its reference, of_dma_configure() doesn't need the node after usage.

Add missing of_node_put() to avoid refcount leak.

Fixes 4b565ca5a2cb ("drm/msm: Add A6XX device support")
---
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +1 -0
index ccc4fcf7a630..a8f6d73197b1 100644
@@ -1919,6 +1919,7 @@ struct msm_gpu *a6xx_gpu_init(struct drm_device *dev)
 	BUG_ON(!node);
 
 	ret = a6xx_gmu_init(a6xx_gpu, node);
+	of_node_put(node);
 	if (ret) {
 		a6xx_destroy(&(a6xx_gpu->base.base));
 		return ERR_PTR(ret);
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 20 lines · Miaoqian Lin

of_parse_phandle() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore.

a6xx_gmu_init() passes the node to of_find_device_by_node() and of_dma_configure(), of_find_device_by_node() will takes its reference, of_dma_configure() doesn't need the node after usage.

Add missing of_node_put() to avoid refcount leak.

Fixes 4b565ca5a2cb ("drm/msm: Add A6XX device support")
---
  drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 1 +
  1 file changed, 1 insertion(+)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +0 -0
index ccc4fcf7a630..a8f6d73197b1 100644

drivers/gpu/drm/msm/adreno/a6xx_gpu.c struct msm_gpu *a6xx_gpu_init(struct drm_device *dev) · line 1925

Quoted 7 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +1 -0
@@ -1919,6 +1919,7 @@ struct msm_gpu *a6xx_gpu_init(struct drm_device *dev)
  	BUG_ON(!node);
 
  	ret = a6xx_gmu_init(a6xx_gpu, node);
+	of_node_put(node);
  	if (ret) {
  		a6xx_destroy(&(a6xx_gpu->base.base));
  		return ERR_PTR(ret);

-Akhil.