media: xilinx-vipp: fix double fwnode_handle_put() in xvip_graph_parse_one()
PATCH 1/1 media: xilinx-vipp: fix double fwnode_handle_put() in xvip_graph_parse_one()
fwnode_graph_get_next_endpoint() already drops the reference on its previous endpoint ep, and the err_notifier_cleanup: path also calls fwnode_handle_put(ep). Calling fwnode_handle_put(ep) inside the loop body therefore drops ep's reference a second time both on the next iteration and on the v4l2_async_nf_add_fwnode() error path.
On OF graphs this underflows the endpoint node's refcount on overlay teardown or repeated probes (deadlocking on devtree_lock when of_node_release() formats %pOF from inside of_get_next_child()):
refcount_t: underflow; use-after-free.
Call Trace: kobject_put of_changeset_destroy free_overlay_changeset of_overlay_remove Call Trace: of_get_parent ... of_node_release of_get_next_child of_graph_get_next_endpoint xvip_graph_parse_one xvip_composite_probe
Drop the redundant fwnode_handle_put(ep) inside the loop.
---
Compiled with W=1 on x86_64 (0 warnings) and verified on v7.4-rc5 with a DT overlay probing xilinx-video: before the fix, a single probe + overlay removal hit refcount_t underflow and repeated rebinds hit the devtree_lock stall inside xvip_composite_probe(); after the fix, 10 overlay cycles x 5 probes passed with 0 errors or warnings.
drivers/media/platform/xilinx/xilinx-vipp.c | 2 -- 1 file changed, 2 deletions(-)
drivers/media/platform/xilinx/xilinx-vipp.c +0 -2
@@ -353,8 +353,6 @@ static int xvip_graph_parse_one(struct xvip_composite_device *xdev, goto err_notifier_cleanup; } -fwnode_handle_put (ep); -/* Skip entities that we have already processed. */ if (remote ==of_fwnode_handle (xdev->dev->of_node) ||xvip_graph_find_entity (xdev, remote)) {
Signature · 1 line
2.53.0