of_dp_aux_populate_bus() acquires two references on np:
(1) of_get_next_available_child() at line 272, and
(2) of_node_get(np) at line 296 via device_set_node().

On the device_register() failure path, put_device() triggers
dp_aux_ep_dev_release() which only does kfree() without calling
of_node_put(). The error cleanup at err_did_get_np only releases
the first reference, leaking the second.

Add of_node_put(np) before goto err_did_set_populated to release
the extra reference on the error path.

Cc: [email protected]
Fixes: fe2e59aa5d70 ("drm: display: Set fwnode for aux bus devices")
Signed-off-by: Wentao Liang <[email protected]>
---
 drivers/gpu/drm/display/drm_dp_aux_bus.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/display/drm_dp_aux_bus.c 
b/drivers/gpu/drm/display/drm_dp_aux_bus.c
index 6e5e3e542290..9dd64cf25d87 100644
--- a/drivers/gpu/drm/display/drm_dp_aux_bus.c
+++ b/drivers/gpu/drm/display/drm_dp_aux_bus.c
@@ -305,6 +305,7 @@ int of_dp_aux_populate_bus(struct drm_dp_aux *aux,
                 * of kfree() directly for error cases.
                 */
                put_device(&aux_ep->dev);
+               of_node_put(np);
 
                goto err_did_set_populated;
        }
-- 
2.34.1

Reply via email to