Skip to contentSkip to conversation

media: xilinx-vipp: fix double fwnode_handle_put() in xvip_graph_parse_one()

PATCH New Yuansheng Yang 1 participant 1 message Dec 4

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

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.

Fixes d079f94c9046 ("media: platform: Switch to v4l2_async_notifier_add_subdev")

---
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
index 786e4f2e6..d997fed57 100644
@@ -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