of_graph_get_endpoint_by_regs() gets a reference to the endpoint node
to read the "bus-width" property but fails to call of_node_put()
to release the reference, causing a reference count leak.

Add the missing of_node_put() call to fix this.

Found via static analysis and code review.

Fixes: d284ccd8588c ("drm/bridge: sii902x: Set input bus format based on 
bus-width")
Cc: [email protected]
Signed-off-by: Miaoqian Lin <[email protected]>
---
 drivers/gpu/drm/bridge/sii902x.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index d537b1d036fb..3a247ac3c7dd 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -1189,8 +1189,10 @@ static int sii902x_probe(struct i2c_client *client)
 
        sii902x->bus_width = 24;
        endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1);
-       if (endpoint)
+       if (endpoint) {
                of_property_read_u32(endpoint, "bus-width", 
&sii902x->bus_width);
+               of_node_put(endpoint);
+       }
 
        endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 1, -1);
        if (endpoint) {
-- 
2.39.5 (Apple Git-154)

Reply via email to