Skip to contentSkip to conversation

drm/omap: dss: Fix refcount leak bugs

PATCH In review Liang He 2 participants 2 messages Jul 22, 2022 – Sep 9, 2022

Subsystems (3)
lore
Share & tools
lore

Liang He

author
#0 lore raw

PATCH 1/1 drm/omap: dss: Fix refcount leak bugs

In dss_init_ports() and __dss_uninit_ports(), we should call of_node_put() for the reference returned by of_graph_get_port_by_id() in fail path or when it is not used anymore.

Fixes 09bffa6e5192 ("drm: omap: use common OF graph helpers")
---
 drivers/gpu/drm/omapdrm/dss/dss.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/omapdrm/dss/dss.c +3 -0
index 0399f3390a0a..c4febb861910 100644
@@ -1176,6 +1176,7 @@ static void __dss_uninit_ports(struct dss_device *dss, unsigned int num_ports)
 		default:
 			break;
 		}
+		of_node_put(port);
 	}
 }
 
@@ -1208,11 +1209,13 @@ static int dss_init_ports(struct dss_device *dss)
 		default:
 			break;
 		}
+		of_node_put(port);
 	}
 
 	return 0;
 
 error:
+	of_node_put(port);
 	__dss_uninit_ports(dss, i);
 	return r;
 }
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 26 lines · Liang He

In dss_init_ports() and __dss_uninit_ports(), we should call of_node_put() for the reference returned by of_graph_get_port_by_id() in fail path or when it is not used anymore.

Fixes 09bffa6e5192 ("drm: omap: use common OF graph helpers")
---
  drivers/gpu/drm/omapdrm/dss/dss.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/gpu/drm/omapdrm/dss/dss.c +1 -0
index 0399f3390a0a..c4febb861910 100644
@@ -1176,6 +1176,7 @@ static void __dss_uninit_ports(struct dss_device *dss, unsigned int num_ports)
  		default:
  			break;
  		}
+		of_node_put(port);
  	}
  }
 
@@ -1208,11 +1209,13 @@ static int dss_init_ports(struct dss_device *dss)
  		default:
  			break;
  		}

drivers/gpu/drm/omapdrm/dss/dss.c static int dss_init_ports(struct dss_device *dss) · line 1221

Quoted 10 lines
drivers/gpu/drm/omapdrm/dss/dss.c +2 -0
+		of_node_put(port);
  	}
 
  	return 0;
 
  error:
+	of_node_put(port);
  	__dss_uninit_ports(dss, i);
  	return r;
  }

Thanks, applying to drm-misc.

Tomi